211k views
2 votes
PLEASE HELP

Read string integer value pairs from input until "Done" is read. For each string read, if the following integer read is less than or equal to 45, output the string followed by ": reorder soon". End each output with a newline.


Ex: If the input is Tumbler 49 Mug 7 Cooker 5 Done, then the output is:


Mug: reorder soon

Cooker: reorder soon

1 Answer

3 votes

Answer: while True:

# Read the string integer pair from input

input_str = input().strip()

if input_str == "Done":

break

string, integer = input_str.split()

# Check if the integer is less than or equal to 45

if int(integer) <= 45:

# Output the string with the message

print(string + ": reorder soon")

Step-by-step explanation:

User Therobyouknow
by
7.3k points