import random number_pool = list(range(1, 91)) computer_card = random.sample(number_pool, 15) computer_card_sorted = sorted(computer_card) player_card = random.sample(number_pool, 15) player_card_sorted = sorted(player_card) def display_cards(): print("Computer card:\n") print(computer_card_sorted) print("====================================") print("Player card:\n") print(player_card_sorted) def lotto_choice(): choice = random.choice(number_pool) number_pool.remove(choice) return choice def the_game(): while number_pool: 

I understand that here I call the number selection function again, but I already just experimented. I would just like to use the returned number from the function, but I wrote something wrong

  print("The random lotto is: " + str(lotto_choice())) lotto_roll = choice ^^^^^^ это значения программа не видит, вроде бы судя по документации должна display_cards() cross_number = input("Do you want to cross out a number") cross_number.lower() if cross_number == "y": player_card_sorted.remove(lotto_roll) # computer_card_sorted.remove(lotto_roll) print(player_card_sorted) if cross_number == "n": continue the_game() 

    1 answer 1

    return choice Returns the value of the choice variable and not its name. Such a variable does not exist at the level above at which you are trying to use it.

    Create it again like this:

     choice = lotto_choice() print("The random lotto is: " + str(choice )) lotto_roll = choice 
    • Thanks helped, I will continue to rake - Sergo Gumkadze