In Python, it is possible to create a one liner code to swap the value of
two variables, this is how
a=2b=4print"a = ",a,"b = ",b# One liner swap of variable using tuples(a,b)=(b,a)print"a = ",a,"b = ",b# To improve the readability # you can write the tuple # without parenthesis, asa,b=b,a
No comments:
Post a Comment