write a python program to read a string from the user and print each character in the given string using index value
Answers
Python String Exercises: Print the index of the character in a string
Sample Solution:-
Python Code:
str1 = "w3resource"
for index, char in enumerate(str1):
print("Current character", char, "position at", index )
Copy
Sample Output:
Current character w position at 0
Current character 3 position at 1
Current character r position at 2
Current character e position at 3
Current character s position at 4
Current character o position at 5
Current character u position at 6
Current character r position at 7
Current character c position at 8
Current character e position at 9