+ Reply to Thread
Results 1 to 2 of 2

Thread: basic python help

  1. #1
    kbjradmin's Avatar
    kbjradmin is offline x10 Elder kbjradmin is an unknown quantity at this point
    Join Date
    Feb 2008
    Location
    Washington State, USA
    Posts
    512

    basic python help

    i am a student taking a python course, and for one of my assignments i have come up with this:

    Code:
    ##  assignmentOne.py
    ##  requests input from the user and then prints out the result for a math equation.
    
    def main():
        print "This program requests two inputs from the user, adds the values,"
        print "and prints the result."
        print
        x = float(input("Please enter the first value: "))
        y = float(input("Please enter the second value: "))
        print
        print "The value of", x, "+", y, "is", x+y
        print
        if input("Type 'restart' to start over or 'done' to quit: ") == "restart":
            main()
        else:
            end()
    
    def end():
        print "Good Bye!"
    
    main()
    i can't get the end part to work right, though.
    the whole rest of the program works, but when i tell the program to restart, it doesn't.

    please help
    Edit:
    nevermind, i figured out the problem.
    at the end i needed a raw_input, not a regular input.
    Last edited by kbjradmin; 10-06-2008 at 02:14 PM. Reason: Automerged Doublepost

  2. #2
    Jose Magsino is offline x10Hosting Member Jose Magsino is an unknown quantity at this point
    Join Date
    Jan 2008
    Posts
    53

    Re: basic python help

    Please change your line
    input("Type 'restart' to start over or 'done' to quit: ")
    to :
    raw_input("Type 'restart' to start over or 'done' to quit: ")

+ Reply to Thread

Similar Threads

  1. Replies: 5
    Last Post: 07-10-2009, 03:30 AM
  2. Python / MySQLdb
    By Korexio in forum Free Hosting
    Replies: 9
    Last Post: 11-29-2007, 08:29 AM
  3. Python/.htaccess help
    By *Face in forum Free Hosting
    Replies: 6
    Last Post: 09-21-2007, 01:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers