Searge
10/9/2018 - 3:15 PM

Python Snippets

Python Snippets

'''
MOST FREQUENT
element in a list
'''

a = [1 2, 3, 1, 2, 3, 2, 2, 4, 5, 1]

print(max(set(a), key = a.count))

'''
using Counter
from collections
'''

from collections import Counter

cnt = Counter(a)
print(cnt.most_common(3))
'''
Об'єднати список в стрічку
'''

a = ['Python', 'is', 'awesome']
print(' '.join(a))
'''
Pythonic way of
VALUE SNAPPING
'''

a, b = 5, 10
print(a, b)

a, b = b, a
print(a, b)