+ 1
Finance app not asking for input
No matter what I change in the code, once I run I’m never asked for input. Then my error messages are telling me that nothing was inputted. Shouldn’t the first provided line of the code (that presumably were not supposed to change) automatically prompt the user to enter data? #• Asks the user to enter the savings savings = input () #•Convert • the user input into a float value and update the variable savings = float (savings) #•Savings grow after 1 year at • a •5%• annual• interest rate balance = savings *1.05 #•Convert the balance into a string and • update the variable balance = str(balance) #•Concatenate the 2 strings to • produce a message message = "Amount in 1 year:."..+ balance #•Display the message
4 Antworten
+ 4
Look at the last line carefully.
You wrote
message="Amount in 1 year.."..+balance
You cannot write those two dots after quote.
The correct code would be :
message="Amount in 1 year:."+balance
+ 4
"Shouldn't the first line of the code ... automatically prompt the user to enter the data?"
Is this from a task or are you doing it in the code playground?
If it's the first, you don't get to do input anything, the program does it itself with the test cases.
If it's the later, the prompt should appear, other than the error Manav Roy pointed out, or you've copied and pasted the code from somewhere and that's put invisible characters which create problems.
Why isn't input() like that?
+ 3
Yeah, some platforms like SoloLearn don’t really support input(), so it won’t ask you anything and just errors out. Try running it somewhere like Replit or on your PC.
Also, tiny fix:
"Amount in 1 year:."..+ balance → should be "Amount in 1 year: " + balance
Hope that helps!
+ 2
I believe it is the one of the practice from the Python course.
Are you sure the code is complete?
The last line in your post is "#•Display the message", but without any print() statement.