Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

How can I use the ".find" and ".append" functions? It seems like online python doesn´t recognise them

+2 votes
asked Aug 1, 2019 by agusabendano (140 points)
I'm trying to solve some school homeworks and we´re studying the programmer functions and I need to use these both and no matter what when I run the programm there´s an error label, and the fuctions don´t change their color in the code like the other ones

1 Answer

0 votes
answered Aug 2, 2019 by anonymous

I'm not sure what classes you are using these methods on, so I'll give generic answers. For .find(), if you use it on a string, it will look something like this:


myStr = "This is a string"

print(myStr.find("i"))

output:

2

This is because the first appearance of the string "i" is at index 2. 

For lists, there is a .append() method used as follow:

myList = [1,"a","b",2]

print(myList)

myList.append("c")

print(myList)

output:


[1, 'a', 'b', 2] <-- before append
[1, 'a', 'b', 2, 'c'] <-- after append

where the argument inside the .append method is the item which you're appending to the list.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...