Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import asyncio
- async def FizzBuzz(i: int):
- await asyncio.sleep(i)
- print("Fizz"*(i%3==0)+"Buzz"*(i%5==0) or i)
- async def SleepFizzBuzz(l,loop):
- tasks = [loop.create_task(FizzBuzz(i)) for i in range(1,l+1)]
- for t in tasks:
- await t
- async def main(loop):
- await SleepFizzBuzz(30,loop)
- if __name__ == '__main__':
- loop = asyncio.get_event_loop()
- loop.run_until_complete(main(loop))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement