Code doesn't wait for raw_input before exiting

A forum for general discussion of the Python programming language.

Code doesn't wait for raw_input before exiting

Postby ravada » Wed Jul 03, 2013 9:35 am

Hi ,

I am a beginner coding in python. I have problem with running the python script.
When ever i import the module "random " and try to run the program it doesn't wait for the user to exit the program inspite of raw_input command.
I tried to debug and the out put looks fine in IDLE(GUI).
Not sure what is going wrong. Can some one help?
Here is the program am trying to run

Code: Select all
import random
heads=0
tails=0
count=0
while count < 100:
    count += 1
    flip=random.randint(1,2)
    if flip == 1:
        heads += 1
    if flip == 2:
        tails += 1
         
print "no of heads:"
print heads
raw_input("press any key to exit")


it works fine in GUI. But doesn't run when i directly try to run the code (by double clicking)
Any help will be appreciated
thanks
Last edited by Yoriz on Fri Jul 05, 2013 8:54 pm, edited 1 time in total.
Reason: Added code tags
ravada
 
Posts: 1
Joined: Wed Jul 03, 2013 9:24 am

Re: Code doesn't wait for raw_input before exiting

Postby Yoriz » Fri Jul 05, 2013 8:56 pm

It works fine for me, does anything at all happen when you double click the py file?
New Users, Read This
Join the #python-forum IRC channel on irc.freenode.net!
Spam topic disapproval technician
Windows7, Python 2.7.4., WxPython 2.9.5.0., some Python 3.3
User avatar
Yoriz
 
Posts: 724
Joined: Fri Feb 08, 2013 1:35 am
Location: UK


Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests