swap_2 Pawan Lakhera February 02, 2018 Swap Two No. with the help of Third Variable a=2 b=3 #swapping logic c=a a=b b=c print "a=",a print "b=",b o/p: a=3 b=2 Comments : Rohit5 August 2018 at 04:54And swapping without third variable:>>> a, b = 2, 3>>> a, b = b, a>>> print('a =', a, ', b =', b)// a = 3 , b = 2ReplyDeleteRepliesPawan Lakhera5 August 2018 at 09:04Thanks.....DeleteRepliesReplyReplyPawan Lakhera5 August 2018 at 09:13And the normal logic.......http://techbackbenchers.blogspot.com/2018/02/swap3.htmlReplyDeleteRepliesReplyAdd commentLoad more... Post a Comment
And swapping without third variable:
ReplyDelete>>> a, b = 2, 3
>>> a, b = b, a
>>> print('a =', a, ', b =', b)
// a = 3 , b = 2
Thanks.....
DeleteAnd the normal logic.......
ReplyDeletehttp://techbackbenchers.blogspot.com/2018/02/swap3.html