Skip to content
← Back to Community
How to loop code back to start if user wants to play again?
Profile icon
Ibrahim87

I need help with a quiz that i made in which three questions are asked until they get it right and their time is recorded.I want to add at the end of the quiz,an option to play again but i don't fully understand how to use for or while loops for this.

Voters
Profile icon
Ibrahim87
Comments
hotnewtop
Profile icon
Petrikboss

Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. HİNDİSTAN GİRİŞ VİZESİ

Profile icon
yiyiwed

It's great for you really to choose one of the best massage therapies for you as per your personal needs. Lots of individuals like to obtain full human body rub company for them. 경기도출장마사지

Profile icon
joyleaf

그렇지만 많은 회원분께서는 단순히 꽁머니를 지급한다고 또는 많은 이벤트를 한다는 각종 홍보 글을 보고만 회원가입을 하고 이용하시다 환전을 할 때 내가 먹튀사이트에 당했다는 상황을 인지하시곤 합니다. 안전사설토토사이트

Profile icon
shahzaib321

What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. Digital Marketing Agency For Small Businesses

Profile icon
shahzaib321

Thank you for another great article. Where else could anyone get that kind of information in such a perfect way of writing? I have a presentation next week, and I am on the look for such information.
beli no 4d online

Profile icon
MuhammadAli174

The content is utmost interesting! I have completely enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great, and your efforts are outstanding! junk car removal abbotsford

Profile icon
MuhammadAli174

I'm really happy to find this site and did enjoy reading useful articles posted here. The ideas of the author was awesome, thanks for the share.sa gaming

Profile icon
MuhammadAli174

We are ready to provide the best service for online lottery players at Gotogel.com . From livechat and whatsapp services 24 hours as well as a safe and easy transaction process. To improve the quality of service, we welcome all criticism, suggestions, and input from you. We guarantee 100% confidentiality of your personal data.Go Togel

Profile icon
Abdul-moizmoiz2

The most important part here is to find a eat-and-run verification site that can do it. Even though the eat-and-run verification site has been saturated for a long time, there are still a handful of eat-and-eat verification sites that can properly verify the food and drink. 먹튀검증커뮤니티

Profile icon
RYANTADIPARTHI

Solution

Use the function name to start from the beginning. Try this code.

play_again = input('want to play again ? ') if play_again == "Y": ask_question1() else: print('ok')

like that. that way, that beginning function will call again.
That should work

Profile icon
MicroSoftHelp

you could try putting the code in a loop that runs only if a certain value is there, for example:

again = 1 for i in range(again) # your code # outside of the loop code at the end again2 = int(input("Do you want to play again? Yes=1 No=2 ") if again2 = 1 again = 1 print("Lets go again!") else: again = 0 print("Goodbye for now!")
Profile icon
KHZ

@IbrahimFromHVS First of all you should put all three questions in one if __name__ == "__main__" statement. Second you can do this to loop the questions if the player wants to play again:

play_again = "yes" while play_again == "yes": # Your Quiz Statements ... # This will prompt the user to ask them if they want to play again # If yes then the loop will repeat else it will break out print ("Do You want to Play Again?") play_again = input("Yes or No: ").lower()