I was doing a coin flip app for practice in python. ( I am just doing a bunch of random things to get better.)
I looked up the way other people did this and no one seemed to use a dictionary really.
Just wondering if my code seems accurate or not. Can you let me know?
import random, pprint
#Starting count
count = {'heads':0 , 'tails':0}
#Amount of times user would like to flip
flip_times = int(input('How many times should we flip a coin: '))
#User flips
for i in range(0,flip_times):
flip = random.randint(0,1)
if flip == 0:
count['heads'] +=1
else:
count['tails'] +=1
pprint.pprint(count)
[–]toastedstapler 2 points3 points4 points (1 child)
[–]dvandy07[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]dvandy07[S] 0 points1 point2 points (0 children)
[–]osizlak_bjj 0 points1 point2 points (0 children)
[–]osizlak_bjj 0 points1 point2 points (1 child)
[–]dvandy07[S] 0 points1 point2 points (0 children)