I teach Python, I want to write a script for divination by Tarot.
There are map values in the dictionary, where the key is the position in the layout for each map.
I understood how to randomly deduce the cards from the list, but I don’t understand what needs to be done so that the key for the first cycle for displays is "1", the second for the key "2" and so on. How to do this with if, else?
import random mag = {1: 'Маг говорит, всё хорошо', 2: 'Маг говорит, всё плохо!'} shut = {1: 'Шут говорит, всё хорошо', 2: 'Шут говорит, всё плохо!'} jritsa = {1: 'Жрица говорит, всё хорошо', 2: 'Жрица говорит, всё плохо!'} emperor = {1: 'Император говорит, всё хорошо', 2: 'Император говорит, всё плохо!'} tarot = [mag, shut, jritsa, emperor] for i in random.sample(tarot, 2): if i: print('Значение карты на 1-ой позиции:', i.get(1)) else: print('Значение карты на 2-ой позиции:', i.get(2)) Now the code simply displays the cards by the first key in the dictionary.