How the index operator works in Python? I’m always stuck in this… From the following code, You can see that we used the for loop to iterate through user_name. We added the username data to password variable. Why there is a username[i-1]? If it’s i minus 1, then there should be 5 characters. How the character “p” replaced to the first index of the username string? Can anyone give me good explanation about the index operator.
password = "" for i in range(0, len(user_name)): password += user_name[i-1] return password