Ive made code that lets me write in numbers in lines, but now, out of all the numbers i get I have to make the comp. print the ones that are nicely divisible by 2 So far this is what ive got:
i = 0
x = 1
y = 0
z = 20
My_file = open("Numbers", 'w')
while i < z:
My_file.write(str(x))
My_file.write("\n")
x = x + 1
i = i + 1
My_file.close()
i = 0
My_file = open("Numbers", 'r')
for line in My_file:
if int(My_file.readline(y)) % 2 == 0:
print(My_file.readline(y))
y = y + 1
The top part work, my problem is the one int(My_file.readline(y)) % 2 == 0 is crap, it says:
invalid literal for int() with base 10: ''.