Python Forum
Help With MyProgrammingLab Code Problem
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help With MyProgrammingLab Code Problem
#3
elif is still an if statment so it requires a test of some sort. The elif by itself is the error. Here is an example :

muffins = 13
cupcakes = 13

while True:
	buying = input ()
	if buying == "0" :
		break
	elif buying == "muffin":
		if muffins > 0:
			muffins -= 1 
		else :
			print ("Out of stock")
	elif  buying == "cupcake":
		if cupcakes > 0:
			cupcakes -= 1
		else :
			print ("Out of stock")
 
print("muffins:", muffins, "cupcakes:", cupcakes)
Reply


Messages In This Thread
Help With MyProgrammingLab Code Problem - by alex_0 - Jan-31-2021, 02:02 AM
RE: Help With MyProgrammingLab Code Problem - by BashBedlam - Jan-31-2021, 03:38 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  MyProgrammingLab wont accept anything I put in chicks4 2 11,609 Feb-10-2019, 11:44 PM
Last Post: chicks4

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020