you can try this.
from math import floor
import sys
s = sys.argv[1]
middle = int(floor(len(s)/2))
for i in range(middle):
print s[i],
if len(s) % 2 == 1:
print s[i+1],
for i in range(middle):
print s[-i + middle - 1],
from math import floor
import sys
s = sys.argv[1]
middle = int(floor(len(s)/2))
for i in range(middle):
print s[i],
if len(s) % 2 == 1:
print s[i+1],
for i in range(middle):
print s[-i + middle - 1],
def mirror(s):
s = s[:len(s)//2] # take the first half of the string
return s + ''.join(reversed(s)) # concatenate with the reversed string
print mirror('COMPUTER')
print mirror('PYTHON')
Title | # Comments | Views | Activity |
---|---|---|---|
passing lists | 9 | 42 | |
regex to extract ip:john | 17 | 58 | |
linux crontab output | 3 | 41 | |
Path to Python | 9 | 48 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
12 Experts available now in Live!