Python assign float to text from input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python assign float to text from input

Hi I am a complete novice need to understand this, what am I doing wrong. I want to assign a value to text from user input (multiple values to multiple texts) https://code.sololearn.com/cIc6nade89yC/?ref=app

20th May 2019, 8:01 PM
Ignatz Janse Van Rensburg
Ignatz Janse Van Rensburg - avatar
4 Answers
+ 5
Hi. You will have to split the user's input. Assuming the values are whitespace separated use the following a = input ().split(" ") Assigning the result of the print() command to a variable does not help much in your case. Remove the print() in the lines where you assign the variables and do the conversion to float there, like x = float(a[1]) This should do the trick. Cheers.C
20th May 2019, 8:11 PM
ChrA
ChrA - avatar
+ 9
a = list(map(float, input().split())) p, r, n = a
20th May 2019, 8:17 PM
Anna
Anna - avatar
+ 3
In too late as your question is already answered but, here is how I fixed it. https://code.sololearn.com/cK9Fsz6RK90F/?ref=app
20th May 2019, 8:17 PM
Russ
Russ - avatar
+ 1
Thanks for the help, will give it another go
20th May 2019, 8:14 PM
Ignatz Janse Van Rensburg
Ignatz Janse Van Rensburg - avatar