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()
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 .
0
Yes, you need to end your parenthesis and use proper indentation in python
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
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)
0
Python doesnt use != btw, uses the keyword not
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
0
<line 5>
NameError: name 'nt' is not defined. Did you mean: 'int'?
0
Бебра
- 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.