PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sen = "I like the Python list syntax Can it be used to create too For example by over pairs of keys and values"
words = sen.split()
words.sort(key = len)
# begin here if list exists
dic = {}
for word in words:
try:
dic[len(word)].append(word)
except:
dic[len (word )] = [word]
maxi = max([len(x) for x in dic.values()])
for i in range(maxi):
for k in dic.keys():
try:
print(dic[k][i], end = " ")
except:
print(" "*k, end = " ")
print()
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run