Thread: Run...

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    51
    Rep Power
    10

    Run...


    I wrote this program....
    I cannot seem to get the program to tell the user that the running total is now over 50.......

    P.S: Total is over 50! You can stop now

    I need your help guys...

    pord_80

    THE PROGRAM IS >>>>>>>>>>>>

    #Count.py
    #This program prompts the user to repeatedly input an integer
    #between 1 to 5(inclusive) and keeps a running total
    #The program then tells the user to stop if the running total
    #is over 50.

    total = 0
    count = 0
    integer = "y"
    integer = raw_input("Please enter,y to input integer: ")
    while integer == "y" or integer !=50:
    integer = input("Enter integer between 1 to 5 inclusive :")
    print"Runing total is not 50"
    total = total + integer
    times = count + total
    print"Your runing total is now",times
    print
    if times == 50:
    print"Total is over 50! You can stop now."
    print"Total was",total,"and the last interger you entered was",count
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    88
    Rep Power
    11
    You can try something like this:
    Code:
    #Count.py
    #This program prompts the user to repeatedly input an integer
    #between 1 to 5(inclusive) and keeps a running total
    #The program then tells the user to stop if the running total
    #is over 50.
    
    times=0
    total = 0
    count = 0
    integer = "y"
    integer = raw_input("Please enter,y to input integer: ")
    while times < 50:
      integer = input("Enter integer between 1 to 5 inclusive :")
      print"Runing total is not 50"
      total = total + integer
      times = count + total
      print"Your runing total is now",times
      print
    print"Total is over 50! You can stop now."
    print"Total was",total,"and the last interger you entered was"  ,count
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    394
    Rep Power
    52
    Hi!

    Another version:
    Code:
    total = 0
    integer = 0
    while total < 50:
        integer = input("Enter integer between 1 and 5: ")
        if integer < 1 or integer > 5:
            print "bad input"
            continue
        total += integer
        print "Total: %i, still under 50" % total
    print "Total: %i, last input: %i" % (total,integer)
    Regards, mawe
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2005
    Posts
    51
    Rep Power
    10

    Thank you guys..


    Thank you guys....
    Just a little adjustment and it works perfectly now.....

    print"Total is over 50! You can stop now."
    print"Total was",total,"and the last interger you entered was" ,integer

IMN logo majestic logo threadwatch logo seochat tools logo