difference between python2 and python3 - int() and input()
问题 I wrote below python code. And I found that python2 and python3 has totally difference running result for input of 1.1. Why is there such difference between python2 and python3? For me, int(1.1) should be 1, then position is valid index 1 within range 0,1,2. So can you please explain why python3 has such result? s=[1,2,3] while True: value=input() print('value:',value) try: position=int(value) print('position',position) print('result',s[position]) except IndexError as err: print('out of index