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
for i in range(3):
if i == 5:
break
else:
print("A", end="")
print("B", end="")
#Python
Please open Telegram to view this post
VIEW IN TELEGRAM