while(True): if x == True: break
b = 10 While(a < b): a += 1
for x in my_list: print(x)
for i,x enumerate(my_list): print(f'[{i:2}] {x}')
for x in sorted(my_list)): print(x)
my_tuple_list = [(12,'c'), (10,'a'), (11,'b')] for x,y in my_tuple_list: print('f{x} {y}')
# sort on second item in tuples my_tuple_list = [(12,'C'), (10,'B'), (11,'a')] ab = sorted(my_tuple_list, key=lambda x: str.upper(x[1])) for a,b in ab: print(f'{a} {b}')
my_dict = {12:'c', 10:'a', 11:'b'} for k in my_dict.keys(): print(f'key={k:4} value={my_dict[k]}') print('----------') for k in sorted(my_dict.keys()): print(f'key={k:4} value={my_dict[k]}')
my_dict = {12:'c', 10:'a', 11:'b'} for v in my_dict.values(): print(f'{v}') print('----------') for v in sorted(my_dict.values()): print(f'{v}')
my_dict = {12:'c', 10:'a', 11:'b'} for k,v in my_dict.items(): print(f'key={k:4} value={v}')