- 1
Why don't work 6th string?
https://code.sololearn.com/c1t7D9jUM74b/?ref=app Please help ppl! Why don't work 6 string? // EOF reading string when input()== 1) #mycode #question #python #beginner #sl liberty_status = int(input()) while(liberty_status != 1 or liberty_status != 0): print("Are you free person? 0/1") liberty_status = int(input()) # string 6 if (liberty_status == 0): print ("0") elif (liberty_status == 1): print ("1") else: print("something middle")
10 Réponses
+ 3
Corrected and working:
https://code.sololearn.com/cR6Jhy1wYJJr/?ref=app
+ 2
You can test multiple inputs by pressing [Enter] (keyboard) before [SUBMIT] (dialog):
6 [enter]
9 [enter]
3 [enter]
1 [SUBMIT]
+ 1
because you use "or" in the while loop.By the way,if you use this while loop ,you don't need to use elif .
0
sololearn code playground throws that error if you ask for A second input. when you enter 6 as an input, it sees that and asks for proper input a second time. thus, you get an error because as I said the second time it asks for input sololearn can't do it
0
As Kirk said you can press enter to multiples inputs or use .split to ask them.
Example:
a,b,c = input ('Type numbers separated by comma').split (',')
print (a,b, c)
Now you can insert 1,5,7 in code playground >> SUBMIT
The code will print: 1 5 7
https://www.sololearn.com/discuss/710210/?ref=app
- 1
# mycode
# Please help me! Why don't work 6 string? // EOF reading string when input()== 1)
liberty_status = int(input())
if liberty_status != 1 and liberty_status != 0:
print("Are you free person? 0/1")
elif liberty_status == 0:
print ("0")
elif liberty_status == 1:
print ("1")
else :
print("something middle")
print ("Inspired by moto San-Marino")
'''The moto of San-Marino
A human is free after the
birthday.
And no one no control himself
Via @Christian Romanovski about
San-Marino
'''
# https://code.sololearn.com/c1t7D9jUM74b/?ref=app
#mycode #question #python #beginner #sl
- 1
@Harry i don't understand yet your ideas bcs the error alarm in #6 string.
Thx thx!
- 1
@Joker told that second input() forbidden in SL. thx!!
- 1
@raphaelrequigo you delete a problem string but the problem save.
One is in the forbidden SL second input().
But thx!!
- 1
I mean because you use "or" in the while loop, it will be in the while loop if you don't input 1 and 0 at the same time(this is impossible). In the while loop, you use input(), but in this app it doesn't allow you to input again. Once you can't input anything, it cause EOF error.
And if you want user input again when they don't input 1 or 0, you don't need to consider if they don't input 1 or 0 in "if", you can do like this
if liberty_status == 0:
print("0")
else:
print("1")
If you want to allow users to input other numbers, just delete the while loop