My issue with this code is that when it is executed it does loop correctly. It just runs once and my goal is to have it run 100 times. I am using Python version 3.1 and could really use some help... Considering I am the only geek with in a 100 miles... You guys are my only hope. :P

flip = int((0))
import random
print("Lets flip a coin 100 times and count how many heads and tails we get")
print("\a")
while flip != 100:
flip += 1
coin = random.randint(1, 2)
head = 0
tail = 0
if coin == 1:
head += 1
else:
tail += 1

print("Heads", head)
print("Tails", tail)
input()

try

flip=flip+1

and remember to hit the code button before you insert your code, it's terrible to read.

here's a program I wrote for an equation using the same loop method a few weeks ago

import urllib.request
import math
whips=int(0)
rate=float(4)
while rate <= float(20):
    improve= rate*float(.15)+rate
    rate= improve
    whips=whips+1
print(whips)

ignore the urllib.request, that's for later in the code.

okay, I ran your code and tweaked it a little bit, I'm not going to give you the answer, but here's a very strong hint.

import math
flip = 0
print("Lets flip a coin 100 times and count how many heads and tails we get")
while flip<=float(99):
    import random
    coin= random.randint(1, 2)
    head= 0
    tail= 0
    if coin ==+1:
        head=head+1
        print('heads')
    else:
        tail=tail+1
        print('tails')
    flip= flip+1
print("Heads", head)
print("Tails", tail)
#why do you think outside of the loop it isn't reflecting?
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.