r1 = Row()
r1.cells = generator_1(3)
r1 = Row(table, 3) # 3я строка таблицы table
, это имело бы смыслfor i in range(5): # нам нужно знать длину строки?
cell_val = next(r1.cells, None)
print (cell_val)
for cell_val in r1:
print (cell_val)
options = {
"Неизвестная песня.mp3": "123",
"Неизвестная песня 2.mp3": "456",
"Неизвестная песня 3.mp3": None, # у этой песни нет сообщения
}
# ну а когда нужно определить песню
track_name = random.choice(list(options.keys()))
# audio_data = open(track_name, 'rb') # зачем это, кстати? Ты отдаёшь имя файла всё равно
option = options.get(track_name) # получаем сообщение для песни
bot.send_audio(message.chat.id, track_name):
if option is not None:
pass # делаешь что тебе надо с option
input('Нажмите Enter чтобы закончить игру')
в конце. global user_id
list.index(x[, start[, end]])
Return zero-based index in the list of the first item whose value is equal to x. Raises a ValueError if there is no such item.
The optional arguments start and end are interpreted as in the slice notation and are used to limit the search to a particular subsequence of the list. The returned index is computed relative to the beginning of the full sequence rather than the start argument.
for i_row, row in enumerate(grid): # row == grid[i_row]
for i_col, value in enumerate(row): # value == row[i_col]
# далее сам
if ... if ... if ... print()
, а if ... elif ... elif ... else: print()
if c != "множення" and "додавання" and "віднімання" and "ділення" :
if x != 2 or 3:
эквивалентен if (x != 2) or (3 != 0):
, что, в свою очередь даёт if (x != 2) or True:
. А что угодно or True даст True, т.е. условие будет всегда выполняться.if x != 2 and x != 3:
или if x not in (2, 3):
Max number of daily application command creates has been reached
# import required libraries
from vidgear.gears import ScreenGear
import cv2
# open video stream with default parameters
stream = ScreenGear().start()
while True:
# read frames from stream
frame = stream.read()
# check for frame if Nonetype
if frame is None:
break
# {do something with the frame here}
# Show output window
cv2.imshow("Output Frame", frame)
# check for 'q' key if pressed
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
# close output window
cv2.destroyAllWindows()
# safely close video stream
stream.stop()
a = (sum(new_matrix[i]) for k in range(matrix_1_height))
for i in a
, и значения будут сгенерированы и получены - но если попробуешь тут же прогнать цикл ещё раз на том же выражении, то не получишь ничего.b = [sum(new_matrix[i]) for k in range(matrix_1_height)]
a = (sum(new_matrix[i]) for k in range(matrix_1_height))
b = list(a) # прогоняем генератор и превращаем его в список