-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Syntax error #514
Comments
Could you please describe the error? Put the error message? |
There was an error in the code because the variable index and item were not defined before using them in the insert() method on the list lst. lst = ['item1', 'item2'] fruits = ['banana', 'orange', 'mango', 'lemon'] ###Note that if you defined these values after calling the insert() method, the code would also not work, since the values must be defined before using the method.### |
You can also try print(lst) to make sure that your code works. |
inserting items into a List
syntax
lst = ['item1', 'item2']
lst.insert(index, item)
fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.insert(2, 'apple') # insert apple between orange and mango
print(fruits) # ['banana', 'orange', 'apple', 'mango', 'lemon']
fruits.insert(3, 'lime') # ['banana', 'orange', 'apple', 'lime', 'mango', 'lemon']
print(fruits)
The above code isn't running for me, keeps showing me ERROR message, same with adding g removing lists, removing items using pop.
Is it that theirs an extension I need to add or download on my VS code??? Please HELP...
The text was updated successfully, but these errors were encountered: