More Handy Functions and the Random Package

More Handy Functions and the Random Package

Unpacking list of tuples:

list_a = ['a', 'b', 'c', 'd', 'e', 'f']
list_b = [1,2,3,4,5,6]
list_c = [99,98,97,96,95,94]

zipped_list = list(zip(list_a, list_b, list_c))

# Unpacking a zipped list:
# You are unpacking each of the tuples
for a,b,c in zipped_list:
	print(a)
	print(b)
	print(c)

Min/Max functions:

list_num = [1,2,3,4,5,6]
max(list_num) # returns the highest number/string in the list
min(list_num) # retunrs the lowest number/string in the list

Random Package:

Getting a random number with randint:

Shuffle function:

Last updated