25th Jun 2024, 1:28 PM
Daniel Nina
Daniel Nina - avatar
5 odpowiedzi
+ 3
Daniel Nina Sololearn runs all console-based programs (non-html programs) as a batch process. Before running your program, Sololearn's batch script scans your source code for any keywords that indicate user input is requested. Regardless of program logic, when it finds an input keyword the batch script prompts you to enter all inputs. This happens before it runs your program. The script stores the entered text into a file. Then the script executes your program in a shell. The program's run-time input gets redirected to come from the input file where the batch script stored the entered text. I hope this clarifies why Sololearn is so quirky with console input.
25th Jun 2024, 2:42 PM
Brian
Brian - avatar
+ 3
Yes, normally you would not be asked for input if user is "A". That is a quirk of playground. When you use List_of_users inside the function, you use the global list variable. In general, global variables should be avoided where possible. You can handle empty input like this: inp = input() or "AnonUser" If the input string is empty, inp will get "AnonUser" as value.
25th Jun 2024, 2:02 PM
Lisa
Lisa - avatar
+ 1
If I understand your question, you want multiple input values to populate the list, right? You only call your function once and pass it the value A. This is what prints regardless of if I leave the input and submit blank. Remove the A, and then it'll take input and output it. You would need to loop the input section of your function in order to add more values. (and remember that Sololearn takes all input as soon as you hit run, it doesn't handle real-time input)
25th Jun 2024, 1:39 PM
Ausgrindtube
Ausgrindtube - avatar
0
No, the goal is for the function to create a user either by providing an argument, or, if blank a input. I know that I could loop it, but I'm just testing things out. Could you please elaborate a bit more on that last paragraph? "And remember that sololearn..." That seems to be what is confusing me
25th Jun 2024, 1:51 PM
Daniel Nina
Daniel Nina - avatar
0
Yeah, looks like I could simplify the question into: user = "none" if False: user = input("type user's name:") print(user) Why do I get a input prompt in here
25th Jun 2024, 1:54 PM
Daniel Nina
Daniel Nina - avatar