+ 4
Please find the mistake in following code
import random print("Hello there, what is your name?") name = input() print (name) import random print( name +" have to go to a path you can see two paths infront. write either 1 or 2 ") path=input() if path== 2: print ("you have fell into deep well you have died") if path== 1: print ("you have encountered a weakened soldier and you kill him")
25 Respuestas
- 2
Specifi the data type of name
+ 10
Convert the path input to integer instead of string using
path = int(input())
+ 8
Why did you import random? (Twice)
+ 6
if - elif - else statements?
if path == 1:
do smth
else:
do smth else for path != 1
+ 6
a = int(input())
b = int(input())
print(a+b)
# when you run program in sololearn
# enter all input at once on diff lines
2
3 #then hit submit
#output
5
+ 4
Dino Gupta is it on sololearn playground?
+ 3
Still not working
+ 3
You have not used random and imported it twice. There is no need of random on your code.
+ 2
Okay
+ 2
Yes input(" ")
+ 2
Dino Gupta use input (" ") not input()
+ 2
https://code.sololearn.com/cJKzp0lVKR2G/?ref=app
You can write it like this. This is what I have wrote after I saw your code.
When you submit your response on sololearn playground, please make sure to first write your name and enter your number on the second line.
Like it if you loved it. :))
+ 1
It is showing eof error
+ 1
What is its alternate of random.
But the main problem is about input statement
+ 1
I just want to know how to have more than one input in one program
+ 1
you can change line 4 to " name = int(input()) " or you can change line 10 and 12 to "if path == '2': " and "if path == '1': "
+ 1
use '2' instead of 2 in if path =='2' or convert into intger
path =input
path =int(path)
0
If you want the input function run more than once,you can define your own function like "get_input",which include the input
function,then use the infinite loop as follow:
while True:
get_input()
Every time an input and output execution finished,it will wait another input.
If you finished the Python3 OOP course here,you will learn.