+ 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.
4 ответов
+ 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.
+ 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}')
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👍
0
Pls check again