+ 1

Python coding playground help please

I am trying to practice coding in python but it keeps on having this message when I hit ‘run’ This is the pop up message: Looks like tour program needs input Use new lines to separate multiple input I am practicing input and output and I cannot see my desired output :( Sample code: name = input(“enter name:”) print(“Hi “ + name)

27th May 2023, 9:14 AM
Bea Ramillano
Bea Ramillano - avatar
7 Respostas
+ 4
The message you're seeing indicates that your program is expecting input from the user, but you haven't provided any input. The input() function in Python waits for the user to enter something before proceeding. In your sample code, when you run it, the program prompts you to enter a name with the message "enter name:". However, if you're running the code in an environment that doesn't provide an interactive console, such as a basic text editor or an online code editor, you won't be able to enter the input directly. To work around this issue, you can modify your code slightly to provide the input directly in the code itself. Here's an example: name = input("enter name:") print("Hi " + name) Change it to: name = "John" # Replace "John" with your desired input print("Hi " + name) By assigning a value directly to the name variable, you can simulate the input without requiring user interaction. In this example, "John" is used as the input, but you can replace it with any desired name or input value. By making this modification, you should be able to see the desired output without encountering the input prompt message.
27th May 2023, 10:35 AM
Hazem Hadj Ahmed
Hazem Hadj Ahmed - avatar
+ 6
It happen because the program dont run on your device but on remote server, you have to provide the input before the run and the server make it avaible to program at runtime. In practice, you will not have real-interactive programs with sl playground (except using html/js codes that will run on your device)
27th May 2023, 9:23 AM
KrOW
KrOW - avatar
+ 6
You can see this code to understand how input/output works in Playground https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
27th May 2023, 9:52 AM
Ipang
+ 3
Thanks so much for the clarifications Hazem Hadj Ahmed Ipang KrOW :) I am using my mobile now to practice code and tried a python IDE app and the input works
27th May 2023, 2:02 PM
Bea Ramillano
Bea Ramillano - avatar
0
Have you added your input? If yes, then please share the code in here.
27th May 2023, 5:11 PM
Danish Zubair
Danish Zubair - avatar
0
Danish Zubair I can’t add an input() in sololearn as what the responses in the thread say. I have added the code in an IDE and it works fine for me
30th May 2023, 2:29 PM
Bea Ramillano
Bea Ramillano - avatar
0
Bea Ramillano You can't display the input text in Sololearn, when the input is asked, but the input text still shows in the console once the input is asked. You can still ask for input, in Sololearn. This is an example of that: https://code.sololearn.com/cof9mjVqWdxQ/?ref=app
30th May 2023, 9:08 PM
Danish Zubair
Danish Zubair - avatar