how to loop this - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: how to loop this (/thread-29092.html) |
how to loop this - dirtdude - Aug-18-2020 guess = input("guess a number between 1 and 50 ") guess = int(guess) if guess == 31: print("yes!The correct answer is " + str(guess) ) else: print("wrong,try again ") this is my code,but I dont know how to loop it,can someone please give suggestions on how to fix it(im a 12 year old kid that just started,so I need some help) RE: how to loop this - ndc85430 - Aug-18-2020 What kinds of loop have you learnt about? If none, how are you learning the language? You should learn about loops in whatever materials you're using. RE: how to loop this - perfringo - Aug-18-2020 Python has built-in help, so you can just type help('while') and help('for') in interactive interpreter (press Q to exit from help) to learn about loops.
RE: how to loop this - pyzyx3qwerty - Aug-20-2020 (Aug-18-2020, 03:24 AM)dirtdude Wrote: guess = input("guess a number between 1 and 50 ")If you are aware of for loops and while loops, I'm pretty sure youu would be knowing the answer. However, to help youu to begin with, a while loop is basically a loop that runs until a given condition is satisfied, whereas a for loop is used for iterating over a sequence RE: how to loop this - Marbelous - Aug-20-2020 In addition to the built-in help Python also has a nice, quick tutorial in its documentation written by Guido van Rossum (inventor of Python). It only takes a couple hours to read through it and you will have all the basics covered. In Windows: Start > Python 3 > Python 3 Manuals. then read the section called The Python Tutorial. |