print python
print('Hello, world!')
list methods python
list.append(x) # append x to end of list
list.extend(iterable) # append all elements of iterable to list
list.insert(i, x) # insert x at index i
list.remove(x) # remove first occurance of x from list
list.pop([i]) # pop element at index i (defaults to end of list)
list.clear() # delete all elements from the list
list.index(x[, start[, end]]) # return index of element x
list.count(x) # return number of occurances of x in list
list.reverse() # reverse elements of list in-place (no return)
list.sort(key=None, reverse=False) # sort list in-place
list.copy() # return a shallow copy of the list
how to create a list in python
# Create a list
new_list = []
# Add items to the list
item1 = "string1"
item2 = "string2"
new_list.append(item1)
new_list.append(item2)
# Access list items
print(new_list[0])
print(new_list[1])
creating a list in python
myList = [value,value,value] #note that you can use any amount of value
#you don not have to use value
list python
#creating the list
whatever_list = ["apple", "orange", "pear"]
#adding things to lists:
whatever_list.append("banana") #adds banana on to the list
#printing something from the list.
#remember, lists start from zero!
print(whatever_list[0]) #This prints apple
print(whatever_list[1]) #This prints orange and so on.
#removing something from a list
whatever_list.remove("orange")
#these are the basic list functions.
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us