Make a Frequency Dictionary From the Elements Of a List

Halo! Today I have to make a python program that meets these conditions: Write a Python program that creates and print a dictionary that maps each element in a list to its corresponding frequency (how many times it occurs in the list). The test should be case-sensitive. Therefore, “A” should not be considered the same element as “a”. I think for today, I’m just going to make it short. Yea… ...

February 25, 2024 · 1 min · SourFox

Bonus assignment: Challenge Add a Key-Value Pair Only if the Key is Not in the Dictionary

Today I was very bored so I checked my bonus assignments and I got this. Write a Python program that adds a new key-value pair to a dictionary only if the key doesn’t exist already. If the key-value pair exists in the dictionary, do not update the existing value. The dictionary should not be modified in this case. Store the new key in the new_key variable and the new value in the new_value variable. Print the final value of the dictionary. ...

November 18, 2023 · 1 min · SourFox