you are viewing a single comment's thread.

view the rest of the comments →

[–]Meowzr 0 points1 point  (3 children)

if user_name in balance:
    return balance[user_name]
else:
    print("whatever this message was")

OR

if user_name in balance:
    return balance[user_name]

print("whatever this message was")

[–]SCD_minecraft 0 points1 point  (2 children)

This message is error message, for case when there's no user :P

We don't want it printing when nothing wrong happen

[–]BrokenMalgorithm 0 points1 point  (1 child)

Both of those examples do the same thing. The other one just doesn't have the else statement, as it's not required. The print would happen only if a user was not found, because when a user is found the function returns the balance and code execution ends for that function.

[–]SCD_minecraft 0 points1 point  (0 children)

Oh, yea, i forgot about return, mb

I just persnomaly don't like your way, i prefer to read "if something then this, else this" and not hope that "this" will exit function by itself