Please open Telegram to view this post
VIEW IN TELEGRAM
data = {'a': [1, 2], 'b': [3, 4]}
data['c'] = data['a'] + data['b']
data['a'].append(5)
print(len(data['c']))#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
fruits = ['apple', 'banana', 'cherry']
fruits[1] = fruits[0] + fruits[2]
print(len(fruits[1]))
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
from itertools import islice
def infinite_seq():
n = 1
while True:
yield n
n *= 2
gen = infinite_seq()
result = list(islice(gen, 5))
print(sum(result))
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM
x = [1, 2]
def f():
x += [3]
try:
f()
except UnboundLocalError:
print("Error")
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM
Please open Telegram to view this post
VIEW IN TELEGRAM