Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech Bugs & Fixes 2 years ago
Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
I am making a text based adventure game in python 3 and I was wondering what the simplest loop is. Using the code I have, it continues to print "whats the number" even when you put the correct number, also giving 9 as input doesnt work. It also doesn't work when I give ("8","9"). Here is my code :
"whats the number"
9
("8","9")
print("whats the number?") required_number = ("8" or "9") while True: number = input() if number == required_number: print ("GOT IT") else: print ("Wrong number try again")
Try this :
print("whats the number?") required_number = [8,9] while True: number = int(input()) if number in required_number : print('GOT IT') break else: print('Wrong number try again')
Sample output in shell :
whats the number? 5 Wrong number try again 2 Wrong number try again 4 Wrong number try again 8 GOT IT
If your required_number or the input will accommodate a string, then you can use this:
required_number
string
required_number = [8,9] required_number = str(required_number) number = None while True: number = input("Write a number: ") if number in required_number: print ("GOT IT") else: print ("Wrong number try again")
Output:
Write a number: 3 Wrong number try again Write a number: 8 GOT IT Write a number: Hi Wrong number try again
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 9 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.