Type() is used to identify a type of a variable.
Types of variables
Int
a = 5 type(a)intFloat
b = 5.0 type(b)floatStr
c = 'Hello' type(c)strList
list1 = [1, 2, 3, 4, 5] list2 = ['a', 'b', 'c', 'd', 'e'] print(type(list1)) print(type(list2))<class 'list'> <class 'list'>
variables should be in the square brackets.
Indexing: used to select a variable in a specific order. The order number starts with 0.
list = ['a', 'k', 'j', 'b', 's', 'v', '!']list[0]'a'Append: used to add another variable to the list.
list_1 = [1, 2, 3, 4, 5]list_1.append(155) list_1[1, 2, 3, 4, 5, 155]Extend: used to merge one list with another list.
list_2 = ['a', 'b', 'c']list_1.extend(list_2) print(list_1)[1, 2, 3, 4, 5, 155, 'a', 'b', 'c']
Comments
Join the discussionNo comments yet. Be the first to comment.