list=input().split()
for x in list:
if int(x) == 0:
break
else:
print(x)
a=input().split()
for x in a:
if int(x) == 0:
break
else:
print(x)
I wonder the difference between receiving the list and a and which method would be better. And
a=input().split()
for x in a:
print(x)
if int(x) == 0:
break
And zero shouldn't be printed out I want to know why 0 is output and ends when I run .
coding python
list=input().split()
for x in list:
if int(x) == 0:
break
else:
print(x)
a=input().split()
for x in a:
if int(x) == 0:
break
else:
print(x)
There is no difference between list
and a
in this code. They're both the same.
a=input().split()
for x in a:
print(x)
if int(x) == 0:
break
Take a good look at the order in which it is executed.
There is print(x)
before the conditional statement, so it is also printed when x = 0
.
© 2024 OneMinuteCode. All rights reserved.