tips 26 tricks in python

Solutions on MaxInterview for tips 26 tricks in python by the best coders in the world

showing results for - "tips 26 tricks in python"
Juana
27 Aug 2019
1test = [1, 2, 3, 4, 2, 2, 3, 1, 4, 4, 4]
2print(max(set(test), key = test.count))
3
Enzo
24 Jan 2018
1class MyName:
2    Geeks, For, Geeks = range(3)
3  
4print(MyName.Geeks)
5print(MyName.For)
6print(MyName.Geeks)
7
Stephan
17 Apr 2017
1import sys
2x = 1
3print(sys.getsizeof(x))
4
Elisa
04 Oct 2016
1from collections import Counter
2def is_anagram(str1, str2):
3     return Counter(str1) == Counter(str2)
4  
5# or without having to import anything 
6def is_anagram(str1, str2): 
7    return sorted(str1) == sorted(str2) 
8  
9print(is_anagram('geek', 'eegk'))
10print(is_anagram('geek', 'peek'))    
11