How to solve this problem:)? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 3

How to solve this problem:)?

If i run a code with e.g. "n=int(input("Enter sth:"))" it shows me the error "ValueError: invalid literal for int() with base 10 : ' ' "

6th Feb 2022, 8:56 PM
Ferhat Nazlioglu
Ferhat Nazlioglu - avatar
9 Answers
+ 7
Ferhat Nazlioglu in sololearn you have to give all inputs in the pop-up that shows when you run the code. Your inputs and your code are then sent to a server to be executed. To give multiple inputs you have to use multiple lines. Sololearn doesn't work with real interactivity.
6th Feb 2022, 11:02 PM
Simon Sauter
Simon Sauter - avatar
+ 1
First i tried "n=float(input("Enter sth:"))" And the code runs perfectly in other interpreter like you link:D so it is solo learn who fuvked up^^ thank you a lot:)
6th Feb 2022, 9:28 PM
Ferhat Nazlioglu
Ferhat Nazlioglu - avatar
0
This is because "int" takes only strings that look like integers. Your code works fine if you give "1" or "42" as input, but an error will be raised if you pass "42.0" as input. If you want to use floats, use "float" instead of "int".
6th Feb 2022, 9:04 PM
Jimmy
Jimmy - avatar
0
i tried that with "float" too but than the output is "...can't convert string to float". i also tried to run the code in another program and the code works so is the problem in solo learn somehow? yester day there was no problem with running the code with an input...
6th Feb 2022, 9:09 PM
Ferhat Nazlioglu
Ferhat Nazlioglu - avatar
0
It should work, so there must be something wrong with your input. Can you please tell me what inputs did you use?
6th Feb 2022, 9:14 PM
Jimmy
Jimmy - avatar
0
The Problem is i cant even put in sth:) after running it shows me this error...
6th Feb 2022, 9:15 PM
Ferhat Nazlioglu
Ferhat Nazlioglu - avatar
0
So did you try: n = float(input("Enter sth:")) ? It's definitely an input error, so maybe something causes your machine to enter some input as soon as you execute the code. Try running the code in this online Python interpreter and see if the error persists: https://www.programiz.com/python-programming/online-compiler/
6th Feb 2022, 9:23 PM
Jimmy
Jimmy - avatar
0
Ferhat Nazlioglu You are correct to assume that Sololearn does not process input the same way as an external IDE. But you can place a prompt in Sololearn using the following format n = int(input()) # input a number
6th Feb 2022, 9:47 PM
Rik Wittkopp
Rik Wittkopp - avatar
0
Tried it and doesnt work...:( Rik Wittkopp
6th Feb 2022, 9:52 PM
Ferhat Nazlioglu
Ferhat Nazlioglu - avatar