Frederik Treusch
Frederik Treusch

Reputation: 3

Why does my function players_list() keep looping when it's only called once?

I'm writing the code for a game and during my so-far testing the function players_list() keeps looping even tough it is only called once. The function sixteen_is_dead(players)'s code is only for testing purposes. Can anyone tell me how to resolve the problem? I want to get the list from players_list() and run sixteen_is_dead(players) with it.

import random


def sixteen_is_dead(players):
    if players[0][1] is True:
        print("Player 1 is not a Human!")


def players_list():
    players = []
    player_count2 = 0
    player_count = int(input("How many players are there?: "))
    for x in range(0, player_count):
        player_count2 += 1
        player_name = input("What's the {}. players name?: ".format(player_count2))
        player_is_bot = input("Is the {}. ? player a bot? J/N: ".format(player_count2))
        if player_is_bot == "J":
            is_bot = False
        elif player_is_bot == "N":
            is_bot = True
        players.append((player_name, is_bot))
    return players
    
        

players_list()
players = players_list()
print(players)

Upvotes: 0

Views: 23

Answers (1)

Eli Eliezer
Eli Eliezer

Reputation: 26

You are calling the function 2 times, you just have to put:

players= players_list()
print(players)

Upvotes: 1

Related Questions