Python does not ask the user

Hello! The problem is with the following code:

def snoepAutomaat ():
  aantal = 0
  totaalBedrag = 0
  muntNum = int (input ("Hoeveel munten wil je in de automaat werpen: "))
  while aantal in range (muntNum):
    munt = float (input ("Waarde Munt: € "))
    totaalBedrag = totaalBedrag + munt
    aantal = aantal + 1
  print ("U heeft €{0} ingeworpen.".format (round(totaalBedrag, 2)))
  print ("")
  print ("Kies uw item: ")
  print ("")
  print ("1. Frikandelbroodje")
  print ("2. ham en kaas crossaint")
  print ("")
  eindBedrag = totaalBedrag
  round (eindBedrag, 2)
  product = int (input ("Voer het nummer van het gewilde product in: "))
  while product <1 or product >5:
    print ("Dit product kan niet gekozen worden.")
    product = int (input("Voer het nummer van het gewilde product in: "))
  if product == 1:
    eindBedrag = totaalBedrag - 0.59
    print ("U kocht een frikandelbroodje, dat koste €0.59")
    print ("U heeft {0} in de automaat.".format (round(eindBedrag,2)))
  elif product == 2:
    eindBedrag = totaalBedrag - 0.49
    print ("U kocht een ham kaas crossaint, dat koste €0.49")
    print ("U heeft {0} in de automaat.".format (round(eindBedrag,2)))
  else:
    print ("Dat lukt niet.")
  print("")
  print ("uw overige geld, €{0}, is uit de automaat gegaan.".format(round(eindBedrag)))

the problem is that python wont ask the user the question.
there are no errors in the code.

Hi David,

I’m afraid I cannot see the image you have sent. All I see is a
blob like this:

[machine|600x500](upload/ZHU7fhxd4HX92DwLrpGti1y5zW.jpeg)

Also see here:

for why you should not post images of your code. (Unless you edit your
code with Photoshop, then it is okay :slight_smile:

Please copy and paste your code as text, and send it. Don’t forget to
mark it as code, so the Discourse software doesn’t mangle the
indentation.

Thank you sir,
I changed it, i hope it can be seen now.

You need to call the function, as follows:

snoepAutomaat()

Be sure not to indent the function call.

Thank you so much,
This is for a school project and im so glad it is finally done.
again thanks!

1 Like