How to swap two strings in Python

2 Answers

0 votes
s1 = "python"
s2 = "java"

temp = s1
s1 = s2
s2 = temp
    
print(s1, s2)



'''
run:

java python

'''

 



answered Sep 24, 2021 by avibootz
0 votes
s1 = "python"
s2 = "java"
 
s1, s2 = s2, s1

print(s1, s2)
 
 
 
'''
run:
 
java python
 
'''

 



answered Aug 23, 2022 by avibootz

Related questions

...