How do you repeat multiple times in python?
How do I make the code reapte such that users can guess the answer to the random number only three times, how do I make it stop at a point? Thanks. This is a random number guessing game, I'm a total beginner to python and can't find anything that helps me on the web (or it may be that I'm just dumb) Show
doctorlove 18.4k2 gold badges47 silver badges60 bronze badges asked Oct 12, 2021 at 12:54
2 Loops and breaks. For example if you want to run the code three times wrap it in a for loop:
or you could make a while loop and break:
answered Oct 12, 2021 at 12:57
haxor789haxor789 5624 silver badges17 bronze badges 1 you could use a for loop:
the number in range() indicates how many times you visit the code inside there are also while loops but for your usecase a for loop should do the trick answered Oct 12, 2021 at 13:00
R98R98 1091 silver badge9 bronze badges 1 Use a looping structure as below answer mentions. Example with |