+ 3
how do i ask multiple questions in python?
I want to use input() and then use it again to define a different variable but i am unsure how, i always receive an error ex: https://code.sololearn.com/cMIHvN9u69JZ/?ref=app
7 Answers
+ 4
Hi, your code is correct (apart from the typo) but the codespace can only take input once per program.
You will need a separate editor to run that code, are you using a desktop or mobile? There are loads of code editors available for either. I use VSCode on desktop and Pydroid / Cxxdroid on my phone.
+ 6
Yes, I agree it is limited but it makes us come up with creative ways to accept input đ
https://code.sololearn.com/ckn3jO4yuPJq/?ref=app
A more beginner friendly version:
https://code.sololearn.com/cvTdHZl4gpl1/?ref=app
+ 6
(this sample is not meant to use with sololearn, but with regular ide's.)
Keith , please allow me to use your code sample to do a modified try like:
input like "Bob 2.17" (return) "Liz 4.94" (return ...). input ends if no input is given but just *return* is pressed.
the input is splitted and then passed as argument to append().
if __name__ == '__main__':
records = []
while inp := input().split():
records.append([inp[0], float(inp[1])])
print(records)
+ 4
The Sololearn platform can accept multiple inputs. Just enter each input on a separate line as stated when the input window pops up đ
+ 2
Keith That slipped my mind, but worth noting this won't work if it repeats in something like a loop though. It will only ask once. It also doesn't allow you to practice using prompts for different information! Its pretty limiting.
+ 2
That's a nice solution, as long as you know all your data at the outset and don't want any trial and error or multiple attempts at something. Neat code though đ
+ 1
yup! usefull code but isnt exactly what i am looking for, my goal is to do something like "square or triangle" then ask the base/height so that the output is only the area of the triange (or something else of that vein)