hoping to get some info on lists and strings.
My assignment is to make a random number generator in the form of a coin flip. As this is somewhat of a starting class, at this point of the term, I am only allowed to use certain built in functions. I was aided by a link the instructor gave us that helped me understand the current code I'm using to generate that list. Here is the code used to generate the list
userin = int(input("enter the number of coin flips: ")
coin = ['H', 'T']
userlist = (random.choices((coin), k=userin))
Now, I was storing the randomly generated list into 'userlist' because I am to also print it as a list. Seems simple enough. I've tried printing it as list, but I'm assuming since I have it coded this way, it will always print it in list format. I know this is simple, and the goal after this will take even more work, but my mind is stuck on this. I will eventually have to count how many "heads" and "tails" were generated, thus the string. Any thoughts or comments are appreciated. -THK
Aucun commentaire:
Enregistrer un commentaire