numbers = [number for number in range(1, 7)]
def main():
for number in numbers:
print(number)
if __name__ == "__main__":
main()
Как сделать, чтобы функция возвращала все элементы?
numbers = [number for number in range(1, 7)]
def numbers_generator(numbers):
for number in numbers:
yield number
def main():
for number in numbers_generator(numbers):
print(number + 1)
if __name__ == "__main__":
main()
try:
if {
'+': lambda o, t, h: o + t == h,
'-': lambda o, t, h: o - t == h,
'*': lambda o, t, h: o * t == h,
'/': lambda o, t, h: o / t == h,
}.get(j)(o, t, h):
print('YES')
else:
print('NO')
except KeyError:
print('Неизвестная функция')
except ZeroDivisionError:
print('Деление на ноль')