Review : Introduction to Strings

Hi I am just done with the review on intro to strings but can’t seem to understand why the coding for the 3rd task is as such… Really confused and hoping to seek some clarification.

Here is the code for review :

Please include the link to the lesson.

What are you specifically confused about?

Where’s your function calls and where are the values that you’re passing through the functions?

See here.

Hi!

I know exactly where you are: Strings Review

I’ll try to explain it as I understood and I hope it helps :smiley:

The third taks asks us to “Create a for loop that iterates through the indices username by going from ‘0’ to ‘len(username)’ and to shift the letters right, at each letter the for loop should add the previous letter to the string ‘password’.”

In order to shift the letters right we have to move the index of the string to the right, correct?:thinking:

Initially I thought it meant ‘username[i+1]’ but then I realised that we had to start our password with ‘username[6]’ :tired_face: so the only way to go is to work with negatives so our password can be in the correct order. :raised_hands:

If we have username[i-1] when i=0 gives us username[-1] which is the same as username[6] (The last letter)

I hope I helped you with your doubt :heart_decoration:

1 Like

Hi the explanation provided is indeed helpful…really helped me visualize much better : )

Thanks a lot!!

1 Like

Hi sorry for the confusion… apologise for the question being quite vague. I got it answered anyways so all is good

2 Likes