Python Coin Toss
Question: I am VERY new to Python and I have to create a game that simulates flipping a
coin and ask the user to enter the number of times that a coin should be
tossed. Based on that response the program has to choose a random number that
is either 0 or 1 (and decide which represents “heads” and which represents
“tails”) for that specified number of times. Count the number of “heads” and
the number of “tails” produced, and present the following information to the
user: a list consisting of the simulated coin tosses, and a summary of the
number of heads and the number of tails produced. For example, if a user
enters 5, the coin toss simulation may result in [‘heads’, ‘tails’, ‘tails’,
‘heads’, ‘heads’]. The program should print something like the following: “
[‘heads’, ‘tails’, ‘tails’, ‘heads’, ‘heads’]

This is what I have so far, and it isn't working at all...

    
    
    import random
    
    def coinToss():
        number = input("Number of times to flip coin: ")
        recordList = []
        heads = 0
        tails = 0
        flip = random.randint(0, 1)
        if (flip == 0):
            print("Heads")
            recordList.append("Heads")
        else:
            print("Tails")
            recordList.append("Tails")
        print(str(recordList))
        print(str(recordList.count("Heads")) + str(recordList.count("Tails")))
    


Answer: You are nearly there:

1) You need to call the function:

    
    
    coinToss()
    

2) You need to set up a loop to call `random.randint()` repeatedly.

