Category : arraylist

I have this list that randomly will choose a different value each time, how can I print the key of the random value that is being selected separately? import random a_dictionary = {"winter": 10, "summer": 30,"spring":20,"autumn":15} values = list(a_dictionary.values()) key = list(a_dictionary.keys()) randomx= random.choice( values) print(randomx) #print(randomx.key) example: random value = 20 spring Source: Python ..

Read more

I am using three lists to format something. However, when assigning values to the lists, I get this exception: File "main.py", line 1 first-operand-list = [”, ‘ ‘, ‘3801’, ‘ ‘, ‘ ‘, ‘123’]; ^ SyntaxError: cannot assign to operator Could anyone explain why? Here is the code: first-operand-list = [”, ‘ ‘, ‘3801’, ‘ ..

Read more