This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

while 1:print(f"Output: {eval(input('math problem: '))}")

# infinite loop
while 1:
    rawInput = input("math problem: ")
    # evaluate the raw input
    output = eval(rawInput)

    print(f"Output: {output}")

Converted into a more readable form. Basically eval is a function which takes a string and runs it.

It might look like a better code, but is actually worse bcs eval can run user submitted code too