0

What is the error

def highlight_word(sentence, word): lst = [] lst = sentence.split() if word in lst: idx = lst.index(word) lst[idx] = lst[idx].upper() new += ' '.join(lst) return new print(highlight_word("Have a nice day", "nice")) print(highlight_word("Shhh, don't be so loud!", "loud")) print(highlight_word("Automating with Python is fun", "fun"))

3rd Apr 2020, 2:36 PM
Somya Sarathi Samal
Somya Sarathi Samal - avatar
2 odpowiedzi
+ 2
The line : new += ' '.join(lst). Remove the + operator new = ' '.join(lst)
3rd Apr 2020, 3:22 PM
Justus
Justus - avatar
+ 1
@Justus thanks for help
4th Apr 2020, 7:13 AM
Somya Sarathi Samal
Somya Sarathi Samal - avatar