This is a simple guessing game I have made, an improvised one. I will do a GUI version of this shortly.
I'm looking for comments and interesting code ideas.
import random sec_no = random.randint(0, 10) ncount = 0 att = 5 while True: sec_no = random.randint(0, 10) ncount = 0 att = 4 minp = input(''' 1-start 2-help 3-quit ''') if minp.lower() == 'start' or minp == '1': while ncount != 4: att -= 1 try: uinp = int(input('Guess the no:')) if uinp == int(sec_no): print('correct!!!!') break else: print('incorrect!!!') print(f'attempts left:{att}') except ValueError: print('invalid value!!!') print(f'attempts left:{att}') if ncount == 3: print('You lose!!') print(f'correct number is :{sec_no}') break ncount += 1 elif minp.lower() == 'quit' or minp == '3': while True: print('are you sure you wanna quit? [Y/N]') linp = input('>') if linp.lower() == 'y': print('Thanks for playing!!') exit() elif linp.lower() == 'n': break else: print("I don't understand that!!!") elif minp.lower() == 'help' or minp == '2': print('''You will be given 3 attempts,within these attempts you'll have to guess the right number from 0-10 good luck!!!''') else: print("I don't understand that!!")
~~~before and after: you don't have to touch indentation. Please heed How do I ask a Good Question?, improving the title of this post, too. \$\endgroup\$