+ 1
While and For
Can this code be make with "while" instead of "for"? https://code.sololearn.com/c1av1rXJE24W/?ref=app
8 ответов
+ 3
This is just an edited version of your code that included both methods d:
https://code.sololearn.com/cD7R4oSDBIkT/?ref=app
+ 2
Generally, using for loops can often be replaced by while loops, with this instance being no exception. All you would really need to do to do so is declare i before the loop and at the end, increase i by 1 to make it similar to how the for loop would run.
i = 2
while i < x:
#Statement(s)
i += 1
+ 2
Arthur No problem! I'm always glad to help out d:
+ 2
Arthur Haha thanks! I don't think I would consider myself a genius, but I do try to help out as many people as I can as I know that it can be difficult to start off learning how to code :)
+ 1
Faisal Can you show me this on code?
+ 1
Faisal Thank you so much.For and while is always difficult for me but you made me understand a lot of how they actually work
+ 1
Faisal Are u like what?A genius that knows everything and keeps travel around the world helping people with your knowledge? lol
+ 1
Faisal ( i saw your profile and realize that you helped a lot of people...)