0
what does the input function do to a string
When I use: print( input ("numbers: ") ) enter 5 for input returns: numbers: 5 would this mean that the input function just adds on (the user inputted number) as a string to the existing string? this won't make sense with the next example though: print( float (input("Enter a number: "))) user inputs 5 print( float ("Enter a number: "+"5") ) explain please because that string can't be converted into a float
1 Respuesta
+ 2
input("numbers:") asks the user for input, using the prompt "numbers:" which is printed on the console. The only thing it actually returns is what the user entered. This can be seen easily when saving the input to a new variable.
x = input("numbers:")
print("You entered the number", x)
This prints:
numbers:You entered the number 5
...to the console. This shows that "numbers" is not a part of the string that is set to x. Hope this helps.