So I am learning python and there is something that bothers me. For the chunk of sample code below:
print("Test")
while True:
print("statement0")
x = input()
print(x)
if x == 1:
print("statement1")
y += input()
print(y)
elif x == 2:
print("statement2")
y += input()
print(y)
elif x == 3:
print("statement3")
y += input()
print(y)
elif x == 4:
print("statement4")
break
The if statements don't seem to be able to execute. After the value of x is printed it will loop back to statement0.
input()returns astr, you should convertxto anintbefore comparing it to otherints or compare it to stringsx == 1can never be true in this code, at best it would bex == '1', but you could also justx = int(input())(the difference is that in the latter case your script would end with an exception if the user enters something that's not a valid integer)