-3

If my variable is:

string = "first second"

How can I change that to print:

second first

annoyingly simple but I can't find a solution for it!

mez0
  • 17
  • 4

1 Answers1

0

I'd split the string on ' ' and then join it back:

s = 'first second'
tmp = s.split(' ')
result = ' '.join((tmp[1], tmp[0]))
Mureinik
  • 297,002
  • 52
  • 306
  • 350