I have to do the following thing"
Write a function that takes a string as input and returns a string composed of only the odd indexes of the string. Note: enumerate() is not available.
now the code I can come up with is
def odd_string(data):
result = ""
for i in (data):
return data[0],data[2],data[4]
print (odd_string("hello"))
how do i actually append these values to a string and how do I make it so that each odd number will be added(without having to write them all out)
nhasn//2odd indices, so you could just do''.join(map(str, range(1, len(s), 2))). That would give you a string composed of the indices. Surely that's not what the question means, but it is what it asked for.