def missing_char(str,n):
front = str[:n]
back = str[n+1:]
return front + back
I don’t really understand what is being said when back is defined, and furthermore I don’t understand how this actually takes out the letter you specify when you enter a word into the function with the “return front + back” part.
Thanks everyone for the help, you all made me understand it better :).
str[:n]copies the string from the start up to, but not including, the n:th character.str[n+1:]copies the string from the (n+1):th character to the end.Adding both these strings will result in all the characters of the original string, except for the n:th character.
str[:n]is a shorthand forstr[0:n], andstr[n:]is a shorthand forstr[n:len(str)].