+ 1
[SOLVED] why no output?
x = int(input()) y = 1 while y >= x: if(y%2 == 0): y = y + 1 else: if(y%3 == 0 and y %5 == 0): print('SoloLearn') else: if(y%5 == 0): print('Learn') else: if(y%3 == 0): print('Solo') else: print(y)
2 ответов
0
Maye your code looks like:
x = input() or 30
y = 1
while y <= int(x):
if(y%2 == 0):
y = y + 1
else:
if(y%3 == 0 and y %5 == 0):
print(y, 'SoloLearn')
else:
if(y%5 == 0):
print(y, 'Learn')
else:
if(y%3 == 0):
print(y, 'Solo')
else:
print(y)
y = y + 1
---------------------
1
3 Solo
5 Learn
7
9 Solo
11
13
15 SoloLearn
17
19
21 Solo
23
25 Learn
27 Solo
29
+ 2
1. while y >= x: # the input x must not be greater than y, or end
2. if(y%2 == 0): y = y + 1 # y = 1, y % 2 = 1 , go to else
3. if(y%3 == 0 and y %5 == 0) # y = 1, not match
4. if(y%5 == 0): # y = 1, not match, go to else
5. if(y%3 == 0) # y = 1, not match, go to else
6. print(y) # y = 1, loop without end condition