+ 1

Programming Fundamentals - Module 14 Quiz

word = 'motorbike ' print (word.find('r')) the correct answer is 3 no 6 - 2 - one error - 4 I lost my 5 hearts, please fix this. Test first.

31st May 2024, 11:18 PM
giomanetta
giomanetta - avatar
4 Answers
+ 7
The correct answer is 4 because indexing starts at zero. https://www.geeksforgeeks.org/JUMP_LINK__&&__python__&&__JUMP_LINK-string-find/ If there is an error with the quiz you should send an email to info@sololearn.com.
31st May 2024, 11:32 PM
Keith
Keith - avatar
+ 6
Joël Northon , if we use: word = "motorbike" print(word.find("o")) the output will be `1`, because the first "o" from the left side is used. we can not find the second "o", except we start iterating over the entire input. for ind, char in enumerate(word): if char == 'o': print(f'character: {char} has index {ind}')
1st Jun 2024, 3:43 PM
Lothar
Lothar - avatar
0
The correct answer is 4 because when we give "motorbike", in indexing we will have: m = 0 o = 1 t = 2 o = 3 r = 4 e.t.c Now when we have: word = "motorbike" print(word.find("r")) here the index of "r" is 4. But if we asked print(word.find("o")) the answer will be 3 because when here the new "o" will cancel the old i hope you'll be satisfied👍
1st Jun 2024, 3:25 PM
Joël Northon
Joël Northon - avatar
0
Pls check again
1st Jun 2024, 4:04 PM
Joël Northon
Joël Northon - avatar