Why is my 21 game code not working /u/Own-Recipe5931 Python Education

the problem to me the try and except even when i make a integer input it still runs the except block code stopping my progress

Here’s my code

import random

startup = random.randint(1,3)

print(“My number is “, startup)

check = startup + 3

nexnum = int(input(“Enter your number n- “))

def check_round():

while nexnum > check:

print(“Your number is too highn Please try again”)

nexnum = int(input(“-“))

while nexnum or startup != 21:

try:

nexnum = int(nexnum)

check_round()

except:

print(“Please enter a whole number”)

nexnum = int(input(“-“))

continue

func1 = nexnum + 3

func2 = nexnum – 1

startup = random.randint(func2, func1)

nexnum = int(input(“Enter your next numbern-“))

continue

submitted by /u/Own-Recipe5931
[link] [comments]

​r/learnpython the problem to me the try and except even when i make a integer input it still runs the except block code stopping my progress Here’s my code import random startup = random.randint(1,3) print(“My number is “, startup) check = startup + 3 nexnum = int(input(“Enter your number n- “)) def check_round(): while nexnum > check: print(“Your number is too highn Please try again”) nexnum = int(input(“-“)) while nexnum or startup != 21: try: nexnum = int(nexnum) check_round() except: print(“Please enter a whole number”) nexnum = int(input(“-“)) continue func1 = nexnum + 3 func2 = nexnum – 1 startup = random.randint(func2, func1) nexnum = int(input(“Enter your next numbern-“)) continue submitted by /u/Own-Recipe5931 [link] [comments] 

the problem to me the try and except even when i make a integer input it still runs the except block code stopping my progress

Here’s my code

import random

startup = random.randint(1,3)

print(“My number is “, startup)

check = startup + 3

nexnum = int(input(“Enter your number n- “))

def check_round():

while nexnum > check:

print(“Your number is too highn Please try again”)

nexnum = int(input(“-“))

while nexnum or startup != 21:

try:

nexnum = int(nexnum)

check_round()

except:

print(“Please enter a whole number”)

nexnum = int(input(“-“))

continue

func1 = nexnum + 3

func2 = nexnum – 1

startup = random.randint(func2, func1)

nexnum = int(input(“Enter your next numbern-“))

continue

submitted by /u/Own-Recipe5931
[link] [comments] 

Leave a Reply

Your email address will not be published. Required fields are marked *