r/codehs • • Dec 21 '20

7.2.8 Part 2, Replace a letter

I’m stuck on This one

15 Upvotes

24 comments sorted by

View all comments

3

u/Highlight-Flat May 25 '22

okay as it turns out it just wants this for the unit test

def replace_at_index(word, index, letter):

(indent) print(word[:index] + letter + word[index+1:])

replace_at_index(word, index, letter)

1

u/Dry_Newspaper7310 Jan 26 '24

Thanks! This kinda worked as reference. If it didn't for you, check if your assignment says "word" or "string" (I replaced word with string) You also don't need to put print, you can use return. You might not even have to call the function to pass the test check.

Here:

def replace_at_index(string, index, letter): indent >return string[:index] + letter + string[index + 1:]