You can use '%' to write related program. If mod of 2 is equal to 0 you can take that character and if it is not equal to 0, you can ignore that character.
def find_odd_vals(str):
final_str = ""
for i in range(len(str)):
if i % 2 == 0:
final_str = final_str + str[i]
return final_str
print(find_odd_vals('python'))
print(find_odd_vals('gaurav'))
You can use '%' to write related program. If mod of 2 is equal to 0 you can take that character and if it is not equal to 0, you can ignore that character.
The above code will print the output as:
'pto'
'gua'