0
Using for loop
x=10 i=0 while i>=6: if x%2==1: print(x) i=i+1 How to write this code with for loop and get the same output?
5 Réponses
+ 4
Brian Technically, your reason is the same as the one described by Sadvik B D.
The solutions are different though. 😉
+ 2
For the above code you won't get any output. Because your if condition become False in every loop.
If you want same code in For loop means 👇👇👇👇.
x=10
for i in range (7):
If x%2==1:
print (x)
i=I+1
+ 1
No need to increment i value manually inside for loop, Sadvik B D
0
Adding to what Sadvik B D said,
there is another reason that it will not produce output. It never enters the while loop because with i=0 the condition i>=6 is false. Did you mean i<=6?
0
And I didn't find any use of this code
Why are you using loop for 7 times and printing the same value(i.e x=10)?