lundi 28 octobre 2019

I'm trying to make a user input dictionary for extra credit in my class and i cant figure out how to properly end the program

my_dict = dict()
more = True
while more:
  bad_input = True

  while bad_input:
    user_input = input("Enter key and value seperated buy commas(,):")
    result = user_input.find(',') 
    print ("Substring ',' found at index:", result )

    if result != -1 and user_input != 'quit':
      bad_input = False
      key , value = user_input.split(",")
      key = key.strip()
      value = value.strip()
      my_dict[key] = value
      print (my_dict)
  if user_input == 'quit':
    print(my_dict)
    break

This is my code and i need it to find the ',' in the user input dictionary and also when you type 'quit' the program needs to end. My teacher is not educated in python enough to help me, please help!

Aucun commentaire:

Enregistrer un commentaire