Python Tutorial 30: Dictionaries And While Loops
ฝัง
- เผยแพร่เมื่อ 31 ก.ค. 2020
- Hey what's going on guys welcome back to the another python tutorial . Yea , so in this video we will see how to use while loops to insert new keys and values into a dictionary. It is exactly same as we did for the for loop .
Link To My Python Tutorial Playlist :
• Python Tutorial 1: Int...
Link To My Front-End Projects Playlist :
• Just using HTML and CS...
I upload programming videos regularly , so if you guys are interested in learning programming you can subscribe and turn the notification bell on , for more such videos.
I recently started front end development , you can check out my front end playlist for more front end tutorials in html , css and javascript.
If you are new to the channel and if you haven't subscribed yet , please go ahead and subscribe .
If you have anything to say about my codes or if you have any doubts regarding what i explain , you can always comment down below about your issue and i will make sure to answer your questions.
Thanks for watching , stay home , stay blessed.
#python #pythonprogramming
thanks for your video!, I was able to use it to understand how to make a self building dictionary, much appreciated
dictionary = {} # dictionary is a container data type for key: value
i=0
while i < 10:
p = str(i)
key = str("Item " + p) # this is the key string
value = i + 1000 # this is the value integer
dictionary[key] = value #this is the line that populates the dictionary each time thru the loop
i = i + 1 #this iterates thru the loop until 10 is reached
print(dictionary)
print(dictionary.get("Item 4"))
I'm glad you enjoyed it ❤️
Thank you very much
Thankyou for this, how do you search for an item in a dictionary using either key or value?
Using "key"
Nice one! What if we want to store name and marks both for a particular roll number?
One key can only hold one value, so im afraid we can't, we will need to add something else to differentiate between two keys
@@HankTheTankCoding if we try to insert another dictionary inside the roll key as values?
@@sanjroks yep you can do that, you can have nested dictionaries no prob with that 😉
@@HankTheTankCoding Alright I am lazy to do that by myself 😄
Haha!