0

What is incorrect?

def main(): game_mode=int(input ("choose game mode\n User Guees, press 1\n CPU Guess, press 2 ")) lower_bound=int(input("enter lower range: ")) upper_bound=int(input("enter upper range: ")) If game_mode != int(): print("please press: 1 or 2 ") main()

11th Oct 2021, 6:31 PM
Dito Shonia
Dito Shonia - avatar
9 Antworten
+ 3
There is many errors in your cide First one is when you calling main function you have written it inside if body it should be proper indent . Then inside function body you missed round brackets in game mode lower bound and in upper bound u have written nt instead of int .
11th Oct 2021, 6:40 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
Yes, you need to end your parenthesis and use proper indentation in python
11th Oct 2021, 7:00 PM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar
0
That's keyboard fault. In .py file all is ok. Only problem i have is that, after run code, if i don't press 1 or 2, if ipress a, b, z, or other, it prints error. I want if game_mode != 1 or 2 go again to selection
11th Oct 2021, 7:02 PM
Dito Shonia
Dito Shonia - avatar
0
Oh ok then all you want to do is contain it in a logical or. If game_mode not 1 or game_mode not 2: Print (“enter 1 or 2)
11th Oct 2021, 7:04 PM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar
0
Python doesnt use != btw, uses the keyword not
11th Oct 2021, 7:06 PM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar
0
Hi Dito! You can use try-except statements or isnumeric() to avoid string inputs. We discussed about the same thing a few days ago. Hope it helps you too. Btw, `!=` is a valid operator in python. try print(7 != 8) output: True https://www.sololearn.com/discuss/2899334/?ref=app
12th Oct 2021, 3:41 AM
Python Learner
Python Learner - avatar
0
<line 5> NameError: name 'nt' is not defined. Did you mean: 'int'?
13th Oct 2021, 11:00 AM
MOHAMED AIT OUBARKA
MOHAMED AIT OUBARKA - avatar
0
Бебра
13th Oct 2021, 1:23 PM
Alex Basenkov
- 1
You are offered a choice of either $1000.000 or $0.01 (one penny) doubled everyday for 30 days.(the resulting amount is doubled everyday) Write a program to calculate the amount that will result from the doubling to understand choices results in a large amount.
12th Oct 2021, 2:45 PM
isaac easie
isaac easie - avatar