0
Why can't I calculate cost with my program?
I've very recently begun learning python. I made a code that takes 2 inputs from the user, one for the distance he/ she wants to travel and then which vehicle he wants to travel in. The code then should do the required calculations and print the total fuel cost for the journey but it doesn't. Please tell me what's wrong with it. https://code.sololearn.com/c5AWvX8EwGc6/?ref=app https://code.sololearn.com/c5AWvX8EwGc6/?ref=app
4 Réponses
+ 3
1 - To print value in Python use syntax
print("ABC") //Right way
print = ("ABC") // Wrong way
2 - for Integer input use this Syntax
dis = int(input())
if you will multiply String value with Integer value, output will print multiple times of integer value. Like
abc * 3 = abcabcabc
3 - To concat int value in string do like this
"You will need Rs. " + str(cost) + "for your journey."
Here you have to first convert int in String then do concatenation.
+ 1
Thanks
+ 1
Very helpful
0
Btw, all are Indian vehicles