+ 1
Hi everyone.I'm trying to run this code of mine but they keep writing. 'No output. Please help me know what's wrong with my code
It is a code that provides the user with the set of prime numbers within the desired range of the user. For example, the set of prime numbers from 30 to 60. Please help me. Code: x=int(input()) y=int(input()) num=list(range(x,y): num.insert(-1,y) i=x while i in num: if (i%2==0) and (i%3==0): continue if (i%5==0) and (i%7==0): continue else: print(i): i+=1
4 Réponses
+ 4
You missed a ')' in line and remove ':'.
Just put num = range(x, y+1) instead of 3,4lines.
And take out i+=1 from else.
It should execute every iteration. Otherwise its infinite loop so you don't get output here.
Edit : ADJEI BERNARD MARFO instead of continue just put i+=1
+ 3
in while you wrote continue for if conditions so when if condition true then it continue with next iteration so without incrementing I value so next each iteration it's value won't change and goes to infinite loop.
Instead of while I in num :
Write for i in num : for loop, will auto increment i
+ 2
Ow nice shortcuts. But please why do they write "no output" after running it.
+ 1
1.
must be:
num = list(range(x,y)):
#two closing braces not one
or just:
num = range(x,y)
2. better
instead of num.insert(-1,y)
num +=[y]
3.much better if:
num = range(x,y+1)