test_list = [[4, 5, 8], [8, 1, 20], [7, 12, 10]]
print("The original list is : " + str(test_list))
K = 2
res = [sub[K] for sub in test_list]
print("The Kth column of matrix is : " + str(res))
Solve Problems by Coding Solutions - A Complete solution for python programming
test_list = [[4, 5, 8], [8, 1, 20], [7, 12, 10]]
print("The original list is : " + str(test_list))
K = 2
res = [sub[K] for sub in test_list]
print("The Kth column of matrix is : " + str(res))
# Using Counter() + split()
from collections import Counter
test_str = 'Python for engineers . Solution for python programs'
print("The original string is : " + str(test_str))
res = Counter(test_str.split())
print("The words frequency : " + str(dict(res)))