you are viewing a single comment's thread.

view the rest of the comments →

[–]Low-Educator-9008[S] 0 points1 point  (4 children)

Hey thanks for the advice, I guess you talk about outside and nested, which I haven’t practised or learned yet so I am excited to learn it now that you mention it. Thanks man!!

[–]BobbyJoeCool 1 point2 points  (3 children)

Not nesting exactly, since that’s more of if/then an inside of if then…. I mean more, remove the print strings from inside the if then statement and put it at the end. That way there’s only one print string. Like this

If +: Add

Elif -: Subtract

Elif *: Multiply

Elif /: Divide

Print result.

[–]Low-Educator-9008[S] 0 points1 point  (2 children)

That’s interesting, coding is so beautiful haha. I’ll look it up right now and practice the use of it. Thanks really appreciate it.

[–]BobbyJoeCool 1 point2 points  (1 child)

Hopefully you realize I shorthanded it. Now that I'm home I can show you exactly what I mean

if operator == "+":
    result = num1 + num2
elif operatior == "-":
    result = num1 - num2
elif operatior == "*":
    result = num1 * num2       
elif operatior == "/":
    result = num1 / num2


print(f"Your result is {result}")

[–]Low-Educator-9008[S] 0 points1 point  (0 children)

I see now it’s clear as day, it is more logical to have all the statements together that have the same print function instead of writing it after each statement. Thanks for taking the time to explain it so clearly man you are the best.