Why can't I calculate cost with my program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

18th Jan 2020, 8:17 AM
Nishchay Mishra
Nishchay Mishra - avatar
4 Answers
+ 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.
18th Jan 2020, 8:32 AM
A͢J
A͢J - avatar
+ 1
Thanks
18th Jan 2020, 8:46 AM
Nishchay Mishra
Nishchay Mishra - avatar
+ 1
Very helpful
18th Jan 2020, 8:53 AM
Nishchay Mishra
Nishchay Mishra - avatar
0
Btw, all are Indian vehicles
18th Jan 2020, 8:17 AM
Nishchay Mishra
Nishchay Mishra - avatar