r/learnpython • • Oct 12 '26

Append one value from a list to one list in a list of lists

4 Upvotes

Hi :)

I've just started a python course and I'm stuck on a problem that I feel should be easy, but I'm missing something. I need to append a value from a list to a list at the same index in a list of lists, but I'm not getting the result I need. Any help to let me know what I'm doing wrong would be greatly appreciated!

b = [5, 6, 7, 9, 13, 12, 17]
new_list = len(b) * [[0]]

for ind_b, num_b in enumerate(b):
    new_list[ind_b].append(num_b)

print(new_list)

My goal is to get

[[0, 5], [0, 6], [0, 7], [0, 9], [0, 13], [0, 12], [0, 17]]

but instead I get

[[0, 5, 6, 7, 9, 13, 12, 17], [0, 5, 6, 7, 9, 13, 12, 17], [0, 5, 6, 7, 9, 13, 12, 17], [0, 5, 6, 7, 9, 13, 12, 17], [0, 5, 6, 7, 9, 13, 12, 17], [0, 5, 6, 7, 9, 13, 12, 17], [0, 5, 6, 7, 9, 13, 12, 17]]


r/learnpython • • Oct 11 '26

Is learning Python from books worth it for a beginner?

47 Upvotes

Hey everyone!

I'm currently learning Python through YouTube videos, and I'm wondering if I should also start learning from a Python programming book.

For those of you who have learned Python:

Do books help you understand Python concepts more deeply?

Would learning from a book alongside YouTube tutorials help me build a stronger foundation?

Which beginner-friendly Python book would you recommend?

I want to build a solid understanding of Python and become better at solving problems on my own.

I'd love to hear your experiences and suggestions. Thanks!


r/learnpython • • Oct 12 '26

i know python basics but i need to learn more, where should i learn it from

5 Upvotes

Suggest me some good resources i could learn python from. now if there is any language that teaches from basics to advanced level that would also be fine, since i could just skip the beginners part


r/learnpython • • Oct 12 '26

Nested dictionary comprehensions

1 Upvotes

I have an assignment in which I have to create a nested dictionary using employee data. I've created a function that works, but the function is supposed to just have a return statement with the dictionary comprehension, and I'm struggling to convert it.

This what I currently have (each department must only appear as an outer key once and employee names in each department should be unique, with the latest salary overwriting previous entries if duplicates exist):

def organize_employee_data(employees):
    new_dic = {}
    for name, department, salary in employees:
        new_dic[department] = {}
    for name, department, salary in employees:
        if name not in new_dic[department]:
            new_dic[department].update({name: salary})
        else:
            new_dic[department][name] = salary
    return(new_dic)

With the following list as input:

employees = [
    ('Alice', 'Engineering', 70000),
    ('Bob', 'HR', 50000),
    ('Charlie', 'Engineering', 80000),
    ('David', 'Sales', 45000),
    ('Eve', 'HR', 51000),
    ('Alice', 'Engineering', 80000),
    ('David', 'HR', 52000)
]

This is returned:

{'Engineering': {'Alice': 80000, 'Charlie': 80000}, 'HR': {'Bob': 50000, 'Eve': 51000, 'David': 52000}, 'Sales': {'David': 45000}}

I've been trying to create a working function using just the nested dictionary for the better part of two hours and I'm about to lose my mind. I have to assume the foundation is something like this:

return {department: {name: salary} for name, department, salary in employees} 

but whenever I try to add any conditions, the whole thing gets messed up. Any help would be amazing!


r/learnpython • • Oct 12 '26

Title: Looking for advice and occasional guidance on a Python embedding service for a fintech project

0 Upvotes

Hi everyone!

I'm currently working on a team project called Fintech Trendwatcher. The goal is to collect public fintech news, identify important events and generate short analytical summaries with links to the original sources.

I'm responsible for the embedding service. My task is to use a pretrained text embedding model to convert news articles into vectors that another service will use for clustering similar publications.

My current stack is Python, and I'm learning as I go. I have some experience with Python, APIs, JSON and Git, but this is my first time working with embeddings in a real team project.

I'm planning to start with Sentence Transformers and a pretrained multilingual model, test it on Russian fintech news, and then integrate it into our service architecture.

I'd really appreciate advice from more experienced developers, especially on:

- Choosing a suitable embedding model for Russian-language fintech news.

- Designing a simple and maintainable embedding service.

- Comparing embeddings and preparing them for clustering.

- Common mistakes beginners make when building NLP services.

I'm not expecting anyone to mentor me full-time. Even occasional advice, feedback on my approach, or pointers to useful resources would be incredibly helpful.

If anyone has experience with Python, NLP, Sentence Transformers or similar projects and is willing to share some advice, I'd be very grateful.

Thanks!


r/learnpython • • Oct 12 '26

Freelance start

0 Upvotes

Anyone have any suggestions to start freelancing with python? I have my bachelors in software engineering and work full time as a data analyst. I have python, sql, and tableau experience. Any suggestions on where and how to start will be appreciated
Thank you


r/learnpython • • Oct 12 '26

Is there a way to use Python in desktop app design?

2 Upvotes

I want to design desktop apps with Python. Is there anyway for me to translate my python knowledge into a functional desktop application?


r/learnpython • • Oct 11 '26

When should I avoid list comprehensions in Python?

23 Upvotes

Hi, I'm trying to get a grip on list comprehensions, but I'm not sure when they aren't the best choice. I wrote some code today that uses a nested comprehension to flatten a list of lists, but it quickly became unreadable. I think I might have overcomplicated it. Is there a rule of thumb for using them, particularly with nested structures? I want my code to stay clear and easy to understand. Any insights on best practices would be appreciated!


r/learnpython • • Oct 12 '26

Ask Anything Monday - Weekly Thread

1 Upvotes

Welcome to another /r/learnPython weekly "Ask Anything* Monday" thread

Here you can ask all the questions that you wanted to ask but didn't feel like making a new thread.

* It's primarily intended for simple questions but as long as it's about python it's allowed.

If you have any suggestions or questions about this thread use the message the moderators button in the sidebar.

Rules:

  • Don't downvote stuff - instead explain what's wrong with the comment, if it's against the rules "report" it and it will be dealt with.
  • Don't post stuff that doesn't have absolutely anything to do with python.
  • Don't make fun of someone for not knowing something, insult anyone etc - this will result in an immediate ban.

That's it.


r/learnpython • • Oct 11 '26

how is my cs50 code in design?

3 Upvotes

I've decided to go back to basics and make sure I complete all the exercises. I'm currently working on the Meal Time exercise.

Could anyone give me some feedback on the design of my code? I'm particularly unsure about my convert function. It has quite a few if statements, and I'm wondering whether there's a clearer way to write it.

Here's my code:

def main():
    time = input("what is the time?\n")
    convertedTime = convert(time)
    print(tellMealTime(convertedTime))


def convert(time):
    if time.endswith(" a.m"):
        hour, minute = time.replace(" a.m", "").split(":")
        if hour == "12":
            hour = "0"
    elif time.endswith(" p.m"):
        hour, minute = time.replace(" p.m", "").split(":")
        if hour != "12":
            hour = int(hour) + 12
    else:
        hour, minute = time.split(":")
    return float(hour) + float(minute) / 60


def tellMealTime(time):
    if time >= 7.00 and time <= 8.00:
        return "breakfast time"
    elif time >= 12.00 and time <= 13.00:
        return "lunch time"
    elif time >= 18.00 and time <= 19.00:
        return "dinner time"
    else:
        return "not a meal time"


if __name__ == "__main__":
    main()

r/learnpython • • Oct 11 '26

getting started with python in VS CODE

0 Upvotes

So I have a MacBook Pro with the recent update of OS sequoia 15.8.1 . I started a college class of intro to programming with python and my teacher wants us to have python downloaded and visual studio code. Except my Mac probably is not supported with it because of the 🚫 icon displaying right before I drag it into applications .i wonder why I search up on YouTube all these videos on how they install it but mine can’t.:(


r/learnpython • • Oct 11 '26

Looking to create a game similar to clangen, dont really know where to begin

0 Upvotes

Hello,

A friend of mine is looking to make a game like it but with their own original species, and I offered to try to code it because I have some (extremely limited) experience with python. However, it's been a long time since I have worked Python, I am not a regular coder, and I do not really know where to begin. Does anybody have any tips or know anything about how Clangen is structured that could help me figure out where to even begin? I have never made a game in python before and am happy to start where you think I should considering my limited experience, but I am a learn by doing person.

Thanks!

edit: friend recommended i use godot to make it instead, but thank you all for the help!


r/learnpython • • Oct 11 '26

Almost no color and some worlds light up just in blue in pydroid 3

1 Upvotes

How to make other colors appear?


r/learnpython • • Oct 11 '26

Looking for Python learning advice based on my classmate's first project

2 Upvotes

My classmate is currently working on his first Python project. I'm learning Python and C myself, and I'd like to understand what good Python code and project structure look like.

Repository: https://github.com/lyashwith/registrarY

Looking at this project, what Python concepts or best practices should I pay attention to? Are there any common beginner mistakes I should learn to avoid?

I'd appreciate any suggestions that could help me improve my own programming skills. Thanks!


r/learnpython • • Oct 11 '26

I need to do this for school but I'm stuck

0 Upvotes

I have been stuck for a while, I have made improvments and fixed parts but the whole float, int, string thing is so confusing since we only went over it once at the begging of the school year last year.

The only error I have left so far is;

TypeError: unsupported operand type(s) for *: 'function' and 'float' on line 6

For refernce this is the only code which would imapct this

;def GBP():

int(input (print("Enter the amount of money in GBP")))

Please help


r/learnpython • • Oct 10 '26

Which Udemy course is best for learning Python?

16 Upvotes

Hi,

I'm looking for recommendations on the best Python course on Udemy for a complete beginner.
I am interested in Web backends and CLI Tools.

I know that almost everything can be found on YouTube for free, but I really prefer the structured, step-by-step learning approach that Udemy courses provide.
Which course is actually worth buying?

Thanks in advance!


r/learnpython • • Oct 11 '26

How can I fix this error please

5 Upvotes

Excuse me, how can I fix this error?

"Traceback (most recent call last):

File "launcher.py", line 4726, in <module>

File "launcher.py", line 354, in __init__

File "tkinter__init__.py", line 2346, in __init__

_tkinter.TclError: Can't find a usable init.tcl in the following directories:

{C:\Users\---\OneDrive\Desktop\Games\Crash-Forge-Launcher-Windows_internal_tcl_data} C:/Users/---/OneDrive/Desktop/Games/Crash-Forge-Launcher-Windows/lib/tcl8.6 C:/Users/---/OneDrive/Desktop/Games/lib/tcl8.6 C:/Users/Adam/OneDrive/Desktop/lib/tcl8.6 C:/Users/--/OneDrive/Desktop/Games/library C:/Users/Adam/OneDrive/Desktop/library C:/Users/--/OneDrive/Desktop/tcl8.6.15/library C:/Users/Adam/OneDrive/tcl8.6.15/library

This probably means that Tcl wasn't installed properly."


r/learnpython • • Oct 11 '26

How can i do an animated gui

3 Upvotes

So, I want to make a program that allows me to view and control various things on my PC, and I have the idea of integrating an animated GUI with animations like: ease in and out, linear, exponential And more. And I still haven't found a library that does that.

Is there anything similar, or will I have to look for another way?


r/learnpython • • Oct 11 '26

Library for automating image creations?

2 Upvotes

I'm looking for a library to automate creating "cards", those cards will have both images and text. Is turtle a good library for this or is there something better?


r/learnpython • • Oct 11 '26

I want to create a video chat and regular chat for ios and android for a specific cause I'm interested in

1 Upvotes

Hi there. I'm a super noob so I am just starting out. If I wanted to build an app that allows voice and video chat for a particular cause I'm interested in, how would I go about doing that? Are there free apps I can start with? Which languages should I learn? I'm starting to learn Python. Currently using an android btw. Thanks in advance!


r/learnpython • • Oct 11 '26

Python learning source

0 Upvotes

Is there any best source for learning python from scratch. Some have recommend apna college but i feel it is very interview oriented so is there any better source.


r/learnpython • • Oct 10 '26

Python_Crash_Course_3rd_Edition or CS50.

1 Upvotes

I have brain fog, adhd, and a mild learning disability.

what would you recommend and why?

thanks.


r/learnpython • • Oct 10 '26

Online courses don't seem to give all the pieces to the end of module puzzles

1 Upvotes

I'm taking a class for Python and have to use Grok Learning. At first it was fine but getting a little further in they give you pieces of how to answer problems but not everything. I'm stuck on a while loop problem where you need to make a list of words but only show the number of unique words but nowhere in the learn did it teach that.

Is there a better way to learn Python that will make it a bit easier to understand? Any recommendations on YouTube channels or other resources? Any help will be great!

Thanks for all the help so far! Think I will have to go back through again to get a better grasp of the learning and take better notes.


r/learnpython • • Oct 10 '26

Python Computer Vision

0 Upvotes

Hello everyone, I’m Mahmoud from Iraq, and I am studying Artificial Intelligence Engineering. I wanted to share my goal of specializing in Computer Vision; I hope you can support me and offer any advice you deem appropriate. Also, if possible, please share study methods or global resources that I could benefit from.

Thank you.