+ 12
Remember that input is always string in Python. You need to convert it to a numerical type (int or float).
28th Jan 2022, 10:41 PM
Simon Sauter
Simon Sauter - avatar
+ 5
Remember that the code requires interaction which doesn't really work on sololearn. On sololearn you have to give all inputs before running.
28th Jan 2022, 11:56 PM
Simon Sauter
Simon Sauter - avatar
+ 4
Use guess = int(input()) to convert the input to integer. Use guess = float(input()) to convert the input to a floating point number. The comparison operator ">" cannot be used between a string and a numerical value.
28th Jan 2022, 10:46 PM
Simon Sauter
Simon Sauter - avatar
+ 3
Or a for loop. Both are possible. If you want the player to guess until they get it right use a while loop. If you want a fixed number of guesses you can use either a while loop or a for loop.
28th Jan 2022, 11:28 PM
Simon Sauter
Simon Sauter - avatar
+ 2
Use a loop to allow multiple guesses.
28th Jan 2022, 11:26 PM
Simon Sauter
Simon Sauter - avatar
28th Jan 2022, 11:55 PM
Simon Sauter
Simon Sauter - avatar
+ 2
It should work in offline IDEs. Some online editors like sololearn require you to give all input upfront so it can be sent to a server together with the code where it is executed. If you're on android you can use pydroid3 as offline IDE. On PC you have lots of options.
29th Jan 2022, 12:05 AM
Simon Sauter
Simon Sauter - avatar
+ 2
You make everything right. But one notice: when you use input(), you ask somebody to input something in your program. Now it is not obvious... In input possible to write some text for user above somebody said that sololearn works not good with inputs. But in other platform you should write int(input("please, input integer number to find out wheather it odd or even")) this hint helps user to understand what to do.
29th Jan 2022, 11:10 PM
Алексей Молодан
Алексей Молодан - avatar
+ 2
It depends on input. Input is even than print if statement. Input is odd than print else statement.
30th Jan 2022, 5:39 PM
RUDRA PRATAP CHAUHAN
RUDRA PRATAP CHAUHAN - avatar
+ 1
Line 10 needs to be indented one more level.
28th Jan 2022, 11:39 PM
Simon Sauter
Simon Sauter - avatar
+ 1
You also need to move the guess into the loop.
28th Jan 2022, 11:40 PM
Simon Sauter
Simon Sauter - avatar
+ 1
You have to define the variable guess before the loop. Use any value (just make sure it's not the same as number, you can just use number + 1). Otherwise the while condition is undefined for the first iteration. The actual guessing via input has to be inside the loop.
28th Jan 2022, 11:46 PM
Simon Sauter
Simon Sauter - avatar
+ 1
Your Mom Or just: print(f"Number is {'odd' if int(input()) & 1 else 'even'}")
30th Jan 2022, 4:39 AM
Œ ㅤ
Œ ㅤ - avatar
+ 1
You can't do a looping input in Sololearn. That is one of the drawbacks in the input system here. Maybe do it in javascript and html if you want interactive programs.
30th Jan 2022, 10:29 AM
Bob_Li
Bob_Li - avatar
+ 1
Why people vote negative... Topic starter just study ...
30th Jan 2022, 10:54 AM
Алексей Молодан
Алексей Молодан - avatar
+ 1
number = int(input("Please enter a number:")) if number % 2 == 0: print("Number is even") else: print("Number is odd")
30th Jan 2022, 6:46 PM
Leon Jananeh
Leon Jananeh - avatar