how to index letters in string code example

Example 1: how to print index of letter

str1 = "w3resource"
for index, char in enumerate(str1):
    print("Current character", char, "position at", index )

Example 2: how to print index of letter

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

Tags:

Misc Example