Question: I have written the following code to complete this question: def swap_values(user_val1, user_val2): return (user_val2, user_val1) if __name__ == '__main__': x = int(input()) y =

I have written the following code to complete this question:

def swap_values(user_val1, user_val2):

return (user_val2, user_val1)

if __name__ == '__main__':

x = int(input())

y = int(input())

x, y = y, x

print(x, y)

For some reason, it passes the first test but when it runs tests 2, 3, and 4 it fails with no error.

Why does this work for the first input but not the rest?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!