🚀 LEVEL UP TO SENIOR:Unlock 500+ Advanced Practical Challenges & Exercises.
🎓 COURSERA PARTNER:Earn professional Google, Meta, and IBM certificates to supercharge your resume.

Project 26: Cryptocurrency Ticker

Python Challenge
Step 1 of 3
Project

Streaming Live Prices over a WebSocket

Connect with websockets.connect(url) and async for message in ws: to receive live price ticks. A WebSocket stays open, pushing new data as it happens — unlike a normal HTTP request/response, you don't have to keep asking "is there anything new yet?".

🎯 Your Task

Please add the exact code shown in the light gray box below to your editor.Do not delete your previous code, just insert these new lines in the correct place!

import asyncio
import websockets

async def stream_prices():
    async with websockets.connect("wss://ticker.example.com/stream") as ws:
        async for message in ws:
            print(f"Price update: {message}")

asyncio.run(stream_prices())