Problems with scripts

lauren.sophia1998 at gmail.com lauren.sophia1998 at gmail.com
Mon Feb 13 11:30:32 EST 2017


Hello! I have 2 python assignments that I just can't figure out. The first one returns the same thing no matter what I input and the second won't accept "done" to stop the program and return answers. Please help! 

1)
print("How old are you: 17, 18, 19, or 20?")
answer = input("> ")
if answer == 17 or 18 or 19 or 20:
    print("Wow, you are old!")
elif answer != 17 or 18 or 19 or 20:
    if type(answer) is int or float:
        print("You just can't follow drections, can you? Choose either 17, 18, 19, or 20.")
        input("> ")
    elif type(answer) is str:
        print("That isn't even a number. Choose either 17, 18, 19, or 20.")
        input("> ")



2)
print("This program keeps track of the prices of items and how many items bought at that price. Enter 'done' to return the answers.")
item_num = 1
total_price = 0
price = input("What is the price of item number " + str(item_num) + " ? ")
total_items = 0
how_many = input("How many items at that price? ")
while price or how_many != "done":
    total_price = int(total_price) + int(price)
    total_items = int(total_items) + int(how_many)
    item_num = item_num + 1
    price = input("What is the price of item number " + str(item_num) + " ? ")
    how_many = input("How many items at that price? ")

if input == done:
    print("The total price is $" + str(total_price) + ". And the number of items for that price is " + str(total_items) + ".")



More information about the Python-list mailing list