Python Forum
user inputs in constructing a dictionary
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
user inputs in constructing a dictionary
#3
How would I go about giving the user the ability to add an unlimited number of key-value entries? Presumably something with a while loop.

Never mind. I figured it out. I didn't realize I could use the same variable over and over again.

latin_vocab = {}
stop_word = ""

while stop_word.lower() != "stop":
    new_key = input("\nLatin word: ")
    latin_vocab[new_key] = input("English meaning: ")
    print(" ")
    print("Current list: " + str(latin_vocab))
    stop_word = input("\nStop? ")
Reply


Messages In This Thread
user inputs in constructing a dictionary - by Exsul - Apr-10-2019, 01:53 AM
RE: user inputs in constructing a dictionary - by Exsul - Apr-10-2019, 02:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to let the user add 'None' to an specific array in a dictionary? noahverner1995 4 1,850 Dec-26-2021, 10:03 AM
Last Post: noahverner1995
  How to write a response if a user inputs a string horuscope42 3 2,280 Apr-29-2020, 03:39 PM
Last Post: deanhystad
  User input & Dictionary tfernandes 5 3,742 Apr-03-2020, 07:12 PM
Last Post: tfernandes
  Perminantly saving user inputs + being able to retrieve it ThatOneGuyNoOneKnowsCodes 1 1,988 Oct-23-2019, 11:28 PM
Last Post: DT2000
  Trying to prompt user for 2 inputs on one line pythonprogrammer 2 2,548 Sep-15-2019, 04:41 PM
Last Post: snippsat
  unit testing a method that asks two user inputs() in console gebel 0 2,178 Apr-03-2019, 07:59 PM
Last Post: gebel
  User Input to Choose from Dictionary anelliaf 9 25,977 Mar-27-2018, 02:22 PM
Last Post: anelliaf
  question regarding user Inputs cibb 10 7,400 Apr-04-2017, 03:34 AM
Last Post: alicarlos13
  code that takes inputs for user name amounts etc and then sends custom message shaumyabrata 5 5,384 Feb-12-2017, 11:37 AM
Last Post: ichabod801

Forum Jump:

User Panel Messages

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