Here is my code in Python:
lst = []
for line in sys.stdin:
line = line.strip().split(" ")
newtup = (int(line[0]), int(line[1]))
lst.append(newtup)
print(lst)
This is my input:
3 2
0 0
5 7
0 2
I want my list to have all the tuples of my input, so like:
[(3, 2), (0, 0), (5, 7), (0, 2)]
I don't know where it went wrong that my list is just not printing. I know my code is working when I tried to print for each iteration and it worked:
lst = []
for line in sys.stdin:
line = line.strip().split(" ")
newtup = (int(line[0]), int(line[1]))
lst.append(newtup)
print(lst)
[(3, 2)]
[(3, 2), (0, 0)]
[(3, 2), (0, 0), (5, 7)]
[(3, 2), (0, 0), (5, 7), (0, 2)]
Is this a glitch in Python? Thanks.