+ 3

How could I print out the same result but with better, short code?

a = "PAYPALISHIRING" i = 0 res = '' while i < len(a): res += a[i] res += ' ' i += 4 s = 1 res1 = '' while s < len(a): res1 += a[s] res1 += ' ' s += 2 t = 2 res2 = '' while t < len(a): res2 += a[t] res2 += ' ' t += 4 final = res + res1 + res2 final1 = final.split() print res print res1 print res2 final = ''.join(final1) print final

12th Mar 2018, 3:43 PM
Nahi Bul
Nahi Bul - avatar
5 ответов
+ 4
please copy your code to code playground
12th Mar 2018, 3:48 PM
Oma Falk
Oma Falk - avatar
12th Mar 2018, 4:55 PM
Oma Falk
Oma Falk - avatar
+ 4
@Nahi nice challenge btw!
12th Mar 2018, 4:56 PM
Oma Falk
Oma Falk - avatar
12th Mar 2018, 4:46 PM
John Wells
John Wells - avatar
+ 2
I did 'zigzag'
12th Mar 2018, 3:59 PM
Nahi Bul
Nahi Bul - avatar