0

Help me to solve this I am not getting output

while true: print("options:") print("enter add to add 2 nmber") print("enter sub to sub 2 number") print("enter mul to multipky 2 number") print("enter dic to divide 2 number") print("enter quite to end program") inputus = input(":") if inputus == "quite": break elif inputus == "add": num1=float(input("enter any number")) num2=float(input("enter another number")) z=str(num1+num2) print("the reasult is:",z) elif inputus == "sub": num1=float(input("enter any number")) num2=float(input("enter another number")) z=str(num1-num2) elif inputus == "mul": num1=float(input("enter any number")) num2=float(input("enter another number")) z=str(num1*num2) elif inputus == "div": num1=float(input("enter any number")) num2=float(input("enter another number")) z=str(num1/num2) else: print("unknown input")

23rd Dec 2019, 10:47 AM
samir thapa srt
samir thapa srt - avatar
6 Answers
+ 1
samir thapa srt , As Mark said; while True: # while true: And add this line: print("the reasult is:", z) After each line containing: z = str(num1 + num2) And check <num2> is not zero when dividing numbers, to prevent error from division by zero. To avoid EOF error, make sure to give inputs properly, and that the last line in input dialog is the word 'quite' (without the quotes). Example (in input dialog) add 5 7 mul 7 6 quite
23rd Dec 2019, 1:16 PM
Ipang
+ 1
Save the code in your profile and share the link instead. It is the recommended way for when your code is rather big (more than 15 lines). Otherwise, you may risk getting your text truncated due to character limits. * You only print the operation result in "add" section, no print in other sections. See this for how to share links: https://www.sololearn.com/post/74857/?ref=app
23rd Dec 2019, 11:01 AM
Ipang
+ 1
https://code.sololearn.com/c0BbIZxk2332/?ref=app here is the code link
23rd Dec 2019, 11:07 AM
samir thapa srt
samir thapa srt - avatar
+ 1
First that "true" needs to be "True" in your while loop. Then you get an EOF error, but I can't spot why.
23rd Dec 2019, 12:02 PM
Mark
Mark - avatar
+ 1
Lpang thank you so much for help.❀ Its mean lots to me❀
23rd Dec 2019, 1:39 PM
samir thapa srt
samir thapa srt - avatar
+ 1
You're welcome, I'm glad if it helps 😁
23rd Dec 2019, 1:50 PM
Ipang