LearnPy Hub
← Async Basics problems
Medium

Async Comprehension

Write an async generator ticker(n) yielding 1 … n with a tiny sleep before each. In main, build [x * x async for x in ticker(n)] and print it, then print the sum of [x async for x in ticker(n) if x % 2].

Input

One integer n ≥ 1.

Output

Two lines.

Sample 1

Input
4
Output
[1, 4, 9, 16]
4

Sample 2

Input
1
Output
[1]
1
solution.py
Output appears here
Async Comprehension · Python practice problem · LearnPy Hub