+ 1
Python beginners!
Python Beginners! What's the most interesting way you've used lists so far? I'm currently learning about lists in Python â like .append(), .remove(), slicing, etc. Curious: what's a small project or fun example where you used a list in a cool or creative way? I'd love to get inspired!
12 Réponses
+ 3
A couple of ways I've used lists:
https://sololearn.com/compiler-playground/cKpE9HWF59s3/?ref=app
https://sololearn.com/compiler-playground/cI2bZvQU4SR0/?ref=app
For practice you can attempt some of the Code Coaches available from the Community tab in app.
Here is Camel to Snake Code Coach:
https://www.sololearn.com/coach/82?ref=app
My solution:
https://sololearn.com/compiler-playground/crril0CGNTES/?ref=app
Keep up the good work and happy coding!
+ 1
Ruchit Gamit Welcome to Sololearn!
As per the community guidelines, the Q&A Discussions forum is for coding questions and NOT general chat. If you have a coding question please start your own topic.
Happy coding!
https://www.sololearn.com/en/Content-Creation-Guidelines/
+ 1
dream success Welcome to Sololearn!
As per the community guidelines, the Q&A Discussions forum is for coding questions and NOT general chat. If you have a coding question please start your own topic.
Happy coding!
https://www.sololearn.com/en/Content-Creation-Guidelines/
0
Haha, same here! đ
I find lists super useful but still wrapping my head around things like slicing and nested lists.
Got any mini project ideas to practice with?
0
You can make a slot machine project
0
Hey everyone
0
Well let's find away
0
import asyncio
import random
class Node:
def __init__(self, node_id, peers):
self.node_id = node_id
self.peers = peers
self.queue = asyncio.Queue()
async def send_message(self, target_node, message):
await target_node.queue.put((self.node_id, message))
async def receive_messages(self):
while True:
sender, message = await self.queue.get()
print(f"Node {self.node_id} received '{message}' from Node {sender}")
async def start(self):
asyncio.create_task(self.receive_messages())
await asyncio.sleep(random.uniform(1, 3))
for peer in self.peers:
await self.send_message(peer, f"Hello from Node {self.node_id}")
async def main():
# Crear nodos
nodes = [Node(i, []) for i in range(3)]
# Asignar peers
for node in nodes:
node.peers = [peer for peer in nodes if peer != node]
# Iniciar nodos
await asyncio.gather(*(node.start() for node in nodes))
await asyncio.sleep(2)
0
Rubén Isaac Palomino Rivasplata What is the purpose of posting this code here? Please use code playground links to post code.
0
That's an awesome way to explore Python! Lists are incredibly versatile, and once you start experimenting, you can do some really fun things.
One cool way I've seen lists used is in a **simple to-do list manager**. You can create a list to store tasks, use `.append()` to add new tasks, `.remove()` to delete completed ones, and slicing to display certain parts of the list. You could even add some interactivity using `input()` to let users manage their tasks dynamically.
Another fun example is a **random story generator**. You can store different elementsâcharacters, settings, and actionsâin separate lists and use `random.choice()` to pick one from each list to create a quirky little story.
Since you're exploring slicing, have you tried reversing a list with `my_list[::-1]`? It's a neat trick that can be handy in many projects!
What kind of projects are you thinking about? Maybe I can help brainstorm something unique!
0
I made a simple quote generator using a list of quotes and random.choice() â it prints a new one each time. Also tried a mini to-do list app using .append() and .remove(). https://www-dgcustomerfirst.com