programming-examples/python/String/Python program to remove the characters which have odd index values of a given string.py

9 lines
233 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def odd_values_string(str):
result = ""
for i in range(len(str)):
if i % 2 == 0:
result = result + str[i]
return result
print(odd_values_string('abcdef'))
print(odd_values_string('python'))