Computer Science

Define two variables first and second so that first = "Jimmy" and second = "Johny". Write a short python code segment that swaps the values assigned to these two variables and prints the results.

Python

Python String Manipulation

4 Likes

Answer

first = "Jimmy"
second = "Johny"
temp = first
first = second
second = temp
print("first =", first)
print("second =", second)

Output

first = Johny
second = Jimmy

Answered By

2 Likes


Related Questions