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

    Join Date
    Oct 2012
    Posts
    1
    Rep Power
    0

    **Please Help!!**


    Hey guys,

    I'm completely new to python and need some help if anyone can do so it will be much apprecated!

    Looking at this code, how do I make so that if the addition is more than 16 it will display 15?

    if choice == 1:
    add1 = input("Adults: ")
    add2 = input("Concessions: ")
    add3 = input("Children: ")
    print add1, "+", add2, "+", add3, "=", add1 *5 + add2 *3 + add3 *2 if ">16" "= 15" ??

    Thank you loads in advance
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,840
    Rep Power
    480
    Code:
    >>> def clip(a,minimum,maximum):
    ...    return min(max(a,minimum),maximum)
    ...
    >>> print(clip(99,0,15))
    15
    >>> print(clip(-988,0,15))
    0
    >>> print(clip(7,0,15))
    7
    >>>
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo