The program is running but not continuing | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 2

The program is running but not continuing

print("Code", "\t\tDescription", "\t\t Price") print("a", "\t\tMenudo with Rice", "\tP50.00") print("b", "\t\tBurger Spaghetti", "\tP70.00") print("c", "\t\tTapa with Rice", "\t\tP60.00") num=eval(input("How many orders do you want to purchase? ")) for i in range(num): order=int(input("Type the code of your choice: ")) quantity=int(input("Type the quantity of your order: ")) a=eval("Menudo with Rice", "\tP50.00") b=eval("Burger Spaghetti", "\tP70.00") c=eval("Tapa with Rice", "\tP60.00") if order==a: print(quantity, a) elif order==b: print(quantity, b) elif order==c: print(quantity, c) total_purchase=eval(input("Total purchase:", a+b+c)) total_payment=eval(input("Total payment: ", total_payment-total_purchase ))

28th Feb 2023, 2:38 PM
Erika Abalora
11 Antworten
+ 4
Here is one more example for you: https://code.sololearn.com/cbVVwleg67sA/?ref=app
2nd Mar 2023, 8:18 PM
JaScript
JaScript - avatar
+ 4
Ela The problem is that you try to calculate price with a string and not a number. For such as task can be used the dictionary. Here you will find your code with minimum needed update: https://code.sololearn.com/cse2GX2JOnaE/?ref=app
2nd Mar 2023, 6:00 PM
JaScript
JaScript - avatar
+ 2
what is missing or wrong?
28th Feb 2023, 2:38 PM
Erika Abalora
+ 2
it should print after typing the code and quantity 2 Tapa with Rice P60.00
28th Feb 2023, 3:17 PM
Erika Abalora
28th Feb 2023, 3:38 PM
Erika Abalora
+ 2
Ela Some mistakes : eval() function takes single argument and it is used to evaluate expression. I think, you are using to convert. accept input of str by input() convert to by int( input() ) No need evaluate. For order, you are converting input to int but comparing by str in order=="a" .. initializing a, b, c to touples, then how a*quantity + ,... works? And why you asking it as input, instead of calculation which you need.
28th Feb 2023, 4:42 PM
Jayakrishna 🇮🇳
2nd Mar 2023, 9:05 AM
Erika Abalora
+ 1
What do you mean by continuing? Actually, what it does by c = eval( "Tapa,..", "\tP60.00") ? What are your expectations by your code and by eval() function?
28th Feb 2023, 3:15 PM
Jayakrishna 🇮🇳
+ 1
Here, Sololearn is not interactive, as you see in PC or laptop. Here, you need to enter all required inputs once only in the pop-up window by line by line separating and submit for execution then. So in pop-up window, add all inputs once, then hit enter.
28th Feb 2023, 3:22 PM
Jayakrishna 🇮🇳
+ 1
Check this code : You can reply for, anything if not understood? https://code.sololearn.com/cPGBX1T5XK86/?ref=app
2nd Mar 2023, 6:33 PM
Jayakrishna 🇮🇳
+ 1
JaScript I got it, thankyouuuuuu
3rd Mar 2023, 12:28 AM
Erika Abalora