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')
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
How to check in python if a log file is being modified? | 5 | 88 | |
Using bootstrap with french text | 13 | 84 | |
general software design question Python related | 1 | 100 | |
Python mysql Insert data error | 3 | 82 |
Join the community of 500,000 technology professionals and ask your questions.
Connect with top rated Experts
18 Experts available now in Live!