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

    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Python Settings Help please!


    Hi, so I am trying to learn Python through a book. And i ran into an issue that i dont know how to solve.

    so the code is celsius = input("___") , when i press enter, the next line asks me what the input is. How do i configure python so that the program will only ask me that when i want to run it? because right now each line is running automatically after every line. Help is much appreciated!
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,890
    Rep Power
    481
    Please try to write more clearly. You sound like me.
    "each line runs after every line".

    I think I get the drift. Define a function. The function code won't execute until you ask.
    Code:
    >>> def c2k():
    ...     c = input('___')
    ...     return float(c)+273.28 # or whatever the constant is
    ... 
    >>> c2k()  # now evaluate the function
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2005
    Posts
    610
    Rep Power
    65
    Using Python3
    Code:
    while True:
        c = input("Enter celcius: ")
        if c:
            break
    Real Programmers always confuse Christmas and Halloween because Oct31 == Dec25

IMN logo majestic logo threadwatch logo seochat tools logo