+ 1
String functions
I have been trying to run this code for a while now but I am unable to and I can't also find the bug even though it keep saying that the bug in line 5. Please can anyone assist me here? https://sololearn.com/compiler-playground/cAyyIw3cw7KL/?ref=app
3 Respostas
+ 6
Try the last line like this:
print(Animal.find("e"))
Just as a note, you notice how the Capital A in Animal changes the colour of the text to blue, that's because the interpreter is thinking that your variable is actually something like a class or function.
Better to do the variable with a lower case a, e.g. animal = "Bee"
Hope it helps!
+ 2
Correct Code :-
#Declares a variable
Animal = "Bee"
#Displays the index of the first letter e
print(Animal.find("e"))
Your earlier code was finding e not "e" , it was treating e as variable not a character to find.
+ 1
Thank you very much, it worked!