Python Forum
Working with dictionaries and keys
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Working with dictionaries and keys
#5
I just did some sample code to show what I am talking about, it is more comprehensive at school, but you will get the idea

dict = {0: "David", 1 : "bill",  2 :"seth"}
print (dict)
ask=0
while ask != 4:
   ask=int(input("Do you want 1) add 2) delete 3) clear list, 4) exit"))
   if ask == 1:
       add=input("Who do you want to add?")
       dict[len(dict)]=add
       print(dict)
   elif ask == 2:
       newdel=int(input("which number do you want to delete?"))
       del dict[newdel]
       print(dict)
Reply


Messages In This Thread
Working with dictionaries and keys - by netrate - Jun-01-2017, 12:28 AM
RE: Working with dictionaries and keys - by netrate - Jun-01-2017, 01:20 AM
RE: Working with dictionaries and keys - by netrate - Jun-01-2017, 02:22 AM
RE: Working with dictionaries and keys - by buran - Jun-01-2017, 02:41 AM
RE: Working with dictionaries and keys - by buran - Jun-01-2017, 02:45 AM
RE: Working with dictionaries and keys - by Larz60+ - Jun-01-2017, 04:46 AM
RE: Working with dictionaries and keys - by wavic - Jun-01-2017, 05:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Question about working with dictionaries Ashcora 13 2,183 Dec-27-2022, 09:09 PM
Last Post: Ashcora
  Best way to support multiple keys in dictionaries mrapple2020 3 2,708 Apr-06-2019, 06:54 AM
Last Post: mrapple2020
  Working with files and dictionaries OmarSinno 1 2,632 Oct-30-2017, 11:02 AM
Last Post: wavic

Forum Jump:

User Panel Messages

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