Quick actions

cmd+k|ctrl+k

Navigation

Languages

List_Data_Types

Snippet info

Language

Python

Visibility

public

Author

kofipsmarte

Created

2026-04-09T01:37:08.350182Z

Updated

2026-04-09T05:08:53.083484Z

#List build in methods

basket = ['a','x','b','c','d','e','d']
bucket = ['i','j','k','l','m','n','o','p','q']

print(basket.count('d'))
#print(basket.sort()) #sort modified the list
print(basket)

print(sorted(basket)) #sorted function, produce a new copy of the list.
print(basket)

new_basket = basket[:]
print(new_basket)

basket.sort()
basket.reverse()
print(basket)

print(len(basket))

bucket.sort()
bucket.reverse()
print(bucket)

print(bucket[::-1]) #list slicing create a reverse list

#Range
print(list(range(1,100)))
print(list(range(110)))

#.join medthod, takes iritable in a string
sentence = ' '
sentence.join(['hi', 'my', 'name', 'is', 'kofi'])
print(sentence.join(['hi', 'my', 'name', 'is', 'kofi']))

new_sentence = ' '.join(['Naana', 'and', 'Ama', 'are', 'kofi\'s', 'twin.'])
print(new_sentence)

#List Unpacking
a,b,c = [1,2,3]

print(a)
print(b)
print(c)

d,e,f, *other = [1,2,3,4,5,6,7,8,9]
print(other)

d,e,f, *other, g = [1,2,3,4,5,6,7,8,9]
print(g)

INFO