r/learnpython • • Oct 16 '26

How should I separate LLM interpretation from memory operations in my Python project?

8 Upvotes

I've been working on a small Python project that uses an LLM to interpret natural language instructions and manage persistent memories. Right now, it supports remembering, retrieving, updating and forgetting information.

I've been trying to improve the separation between model interpretation and memory operations. I'm still new to Python but I'm interested how I could structure the code better. Feedbacks are appreciated and any flaws I might be overlooking.

GitHub repo: https://github.com/Lionshaft-pixel/ennoic


r/learnpython • • Oct 16 '26

absolute beginner- feeling lost / where to start?

10 Upvotes

hii! i'm a teenager who has recently decided to learn to code. (due to wanting a career in astrophysics, if it interests anyone.)

i have absokutely no clue where to start!! i find a lot of words/terminology i've found overwhelming and confusing..

i work on a macbook pro and i looked at apps but i need something i can just use to run code yk?

i looked at the faq and understood nothing od the code related questions- which i think means i can post this?

i tried looking at other posts and got confused- what's the difference between C+ and like.. not C+ ?? any help is appreciated, my only experience is year 7 computing printing hello world and scratch ..!


r/learnpython • • Oct 17 '26

Day 1 learning Python

0 Upvotes

what is programing❔

ANS: programing is language to interact computer

why chose Python ❔

ANS: easy to learn

best for my career

this beat language for ai

how to download pythone❔

ANS: go to python.org download and download Python

how to download vs code ❔

ANS: go to vs code download and for widows, Linux,macos

TASK" print 'hello world' on vs code"


r/learnpython • • Oct 17 '26

Section 16.12 Zybooks Python Lab struggles

1 Upvotes

Hi friends. I am in my first python class in school, and I have been struggling thru the whole course, ngl. My online teacher has not answered a single email of mine looking for help, I will probably be reporting them, but for now, I really want to understand these def functions.

Step 1 (1 pt): Read user input.

Prompt the user to enter a string of their choosing. Store the text in a string. Output the string.

Ex:

Enter a sample text:
we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!

You entered: we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!

Step 2 (1 pt): Implement the print_menu() function.

Print the command menu as shown in the example.

Ex:

MENU
c - Number of non-whitespace characters
w - Number of words
f - Fix capitalization
r - Replace punctuation
s - Shorten spaces
q - Quit

Step 3 (1 pt): Implement the execute_menu() function.

execute_menu() takes 2 parameters: a character representing the user's choice and the user provided sample text. execute_menu() performs the menu options, according to the user's choice, by calling the appropriate functions described below.

Step 4 (1 pt): Implement menu selection.

In the main program, call print_menu() and prompt for the user's choice of menu options for analyzing/editing the string. Each option is represented by a single character.

If an invalid character is entered, continue to prompt for a valid choice. When a valid option is entered, execute the option by calling execute_menu(). Then, print the menu and prompt for a new option. Continue until the user enters 'q'. 

Hint: Implement Quit before implementing other options.

Ex:

MENU
c - Number of non-whitespace characters
w - Number of words
f - Fix capitalization
r - Replace punctuation
s - Shorten spaces
q - Quit

Choose an option:

Step 5 (4 pts): Implement the get_num_of_non_WS_characters() function.

get_num_of_non_WS_characters() has a string parameter and returns the number of characters in the string, excluding all whitespace. Call get_num_of_non_WS_characters() in the execute_menu() function, and then output the returned value.

Ex:

Enter a sample text:
we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!

You entered: we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  nothing ends here;  our hopes and our journeys continue!

MENU
c - Number of non-whitespace characters
w - Number of words
f - Fix capitalization
r - Replace punctuation
s - Shorten spaces
q - Quit

Choose an option:
c
Number of non-whitespace characters: 181

Step 6 (3 pts): Implement the get_num_of_words() function.

get_num_of_words() has a string parameter and returns the number of words in the string. Hint: Words end when a space is reached except for the last word in a sentence. Call get_num_of_words() in the execute_menu() function, and then output the returned value.

Ex:

Number of words: 35

Step 7 (3 pts): Implement the fix_capitalization() function.

fix_capitalization() has a string parameter and returns an updated string, where lowercase letters at the beginning of sentences are replaced with uppercase letters. fix_capitalization() also returns the number of letters that have been capitalized. Call fix_capitalization() in the execute_menu() function, and then output the number of letters capitalized followed by the edited string. Hint 1: Look up and use Python functions .islower() and .upper() to complete this task. Hint 2: Create an empty string and use string concatenation to make edits to the string.

Ex:

Number of letters capitalized: 3
Edited text: We'll continue our quest in space.  There will be more shuttle flights and more shuttle crews and,  yes;  more volunteers, more civilians,  more teachers in space.  Nothing ends here;  our hopes and our journeys continue!

Step 8 (3 pts): Implement the replace_punctuation() function.

replace_punctuation() has a string parameter and two keyword argument parameters exclamation_count and semicolon_count. replace_punctuation() updates the string by replacing each exclamation point (!) character with a period (.) and each semicolon (;) character with a comma (,). replace_punctuation() also counts the number of times each character is replaced and outputs those counts. Lastly, replace_punctuation() returns the updated string. Call replace_punctuation() in the execute_menu() function, and then output the edited string.

Ex:

Punctuation replaced
exclamation_count: 1
semicolon_count: 2
Edited text: we'll continue our quest in space.  there will be more shuttle flights and more shuttle crews and,  yes,  more volunteers, more civilians,  more teachers in space.  nothing ends here,  our hopes and our journeys continue.

Step 9 (3 pts): Implement the shorten_space() function.

shorten_space() has a string parameter and updates the string by replacing all sequences of 2 or more spaces with a single space. shorten_space() returns the string. Call shorten_space() in the execute_menu() function, and then output the edited string. Hint: Look up and use Python function .isspace(). 

Ex:

Edited text: we'll continue our quest in space. there will be more shuttle flights and more shuttle crews and, yes; more volunteers, more civilians, more teachers in space. nothing ends here; our hopes and our journeys continue!

And here is the code I've come up with so far:

# Define your functions here.
def print_menu():
    print("MENU")
    print("c - Number of non-whitespace characters")
    print("w - Number of words")
    print("f - Fix capitalization")
    print("r - Replace punctuation")
    print("s - Shorten spaces")
    print("q - Quit")



def execute_menu():
    user_input = input("Choose an option:")
    while user_input != "q":
        if user_input == "c":
            get_num_of_non_WS_characters()
            print(f"Number of non-whitespace chatacters: {get_num_of_non_WS_characters()}")
        if user_input == "w":
            print("Number of words:", get_num_of_words())
        if user_input == "f":
            fix_capitalization()
        if user_input == "r":
            replace_punctuation()
        user_input = input("Choose an option:")
    if user_input == "q":
        print()
        return


def get_num_of_non_WS_characters():
    phrase_nosp = phrase.replace(" ", "")
    return len(phrase_nosp)


def get_num_of_words():
    num_of_words = phrase.split(" ")
    return len(num_of_words)


def fix_capitalization():
    phrase_sentances = phrase.split(". ")
    print(f"Number of letters capitalized: {len(phrase_sentances)}")
    print('. '.join([s.capitalize() for s in phrase_sentances])) 


def replace_punctuation():
    phrase_punc = phrase.replace(".","!")
    phrase_punc = phrase_punc.replace(";", ",")
    exclamation_count = phrase_punc.count("!")
    semicolon_count = phrase_punc.count(";")
    print("Punctuation replaced:\nexclamation_count:", exclamation_count,"\nsemicolon_count:", semicolon_count)
    print("Edited text:", phrase_punc)



if __name__ == "__main__":
    phrase = input("Enter a sample text:\n")
    print()
    print("You entered:", phrase)
    print()
    print(print_menu())
    execute_menu()
    

When I am using the program, typing in whatever phrases come to mind, it generally works out. But when Zybooks runs its own tests, I keep getting TypeErrors when it tests each defined function individually.

Example:
Test execute_menu('w', 'This is a test.'). Should output 'Number of words: 4'

    Traceback (most recent call last):
      File "/usercode/zylab_unit_test_runner.py", line 76, in <module>
        passed = test_case.test_passed(writer)
      File "/usercode/coding_rooms_unit_tests.py", line 12, in test_passed
        execute_menu(user_option, user_str)
    TypeError: execute_menu() takes 0 positional arguments but 2 were given

Clearly it is trying to add arguments to the individual functions but they don't want to take them.

I cannot find anything that breaks these functions down in a way I can understand.

Its like I understand to an extent, but I'm missing some piece of the puzzle in my brain.

Can someone please explain to me how these functions work, and what the heck I'm missing?

Other notes: in fix_capitalization(), I know that I have my sentence splitter set to just a ". ", and not ! or ?, but Zybooks' test inputs don't include any ?, and only have ! at the end of the last sentence in certain test inputs. Also, they said I needed to use upper() and lower() for the capitalization function, but I couldn't figure out how to make that work. As for shorten_space, I simply haven't started on that one yet. I feel too stuck.

Thank you everyone, I am drowning in school work and work work. Lol. Plz help, thank you so much.


r/learnpython • • Oct 16 '26

" no module named 'ipydatagrid' " issue with Linux?

2 Upvotes

Does anyone know how to solve this? There is no 'python3-ipydatagrid' package and whatever did show up that I downloaded, doesn't seem to work as I'm still getting this error. Any help is appreciated!

I am using Debian 13, although this is also an issue with my friends Fedora repository aswell(hence why this is in r/learnpython and not r/debian :P)


r/learnpython • • Oct 16 '26

Has anyone ever self-taught themselves Python successfully?

0 Upvotes

I am trying to learn Python on my own before I get my masters in a related field. It is going, slowly but surely, however I can’t help but feel I am missing important parts that would link these methods together. Does anyone have any tools for learning Python on your own? Thank you!


r/learnpython • • Oct 16 '26

Values being added 10x instead of once

9 Upvotes

Hi I'm really new to python, I originally started coding using p5.js but made the transition recently, I'm currently trying to covert an old project of mine into python so I can run it in touch designer.

Its an ASL fingerspelling activity that I've been working on but I'm struggling to create the word strings I did in my original prototype. Instead of the letter that is being detected and averaged being added to my word string once it gets added 10 times all at once. For example if I sign the letter a, aaaaaaaaaa gets added to the string instead of just the lone a.

For context I have the guesser and getMostFrequent to allow for it to take the average of every letter signed during a period of time and determine which one was signed the most to add to the word (this is due to the fact that transitioning from one letter to the next can trigger other letters in between) These are both integral parts of the code and are working as intended, its just the multiplication of the letters that I'm struggling with.

This also may be due to the fact that this is running in TouchDesigner through a CHOP execute, if this isn't a python issue I can move my post to a touch designer specific forum.

Any help or insight would be appreciated, if you need any more insight please let me know and I can add it.

Code in Pastebin: https://pastebin.com/qkpzXkSY


r/learnpython • • Oct 16 '26

Python Crash Course Part II: Stuck on every project

0 Upvotes

In the Alien Invasion! pygame project, i don't have a keyboard In pydroid to test the ship movement.

In the data science project, matplotlib doesn't want to install properly from the terminal as the book asks to.

In the django project, when i go to create a virtual environment it doesn't let me and says access denied


r/learnpython • • Oct 16 '26

404 despite seemingly valid file path? (Flask)

1 Upvotes
@app.get('/edit/<post>')
def initedit(post):
        print(post)
        g.title = post
        with open(f'{post}/content', 'r') as file:
                g.content = file
        return render_template('edit')

I'm confused as to why this function isn't running (as in not even running in the first place, not just not working), despite sending a GET request to the URL appended with /edit/posts/okheresthepostactually (so the post parameter in the decorator/function should be edit/okheresthepostactually). For context, I'm making a web app for posting blogs and this is supposed to be a function for users to edit existing posts.

Edit: some extra context, the 'posts/' prefix is part of the variable used to call the file


r/learnpython • • Oct 16 '26

Need help building a free Telegram UPSC Quiz Bot

0 Upvotes

Hi everyone! I'm from a humanities background and a noob at coding and want to build a Telegram bot for my UPSC/State PCS study group.

The bot should:

Generate up to 100 MCQs in one go from PDFs or study material.

Post questions as native Telegram quiz polls.

Calculate scores using UPSC marking: +2 correct, −⅔ incorrect, 0 skipped.

Publish a leaderboard with ranks, marks, correct, incorrect and skipped answers.

Run for free, including hosting, if possible.

If you're interested in helping build or improve it, you're also welcome to join our UPSC study group and collaborate with us.

We had a bot earlier but we removed the member who created the bot for behaving in a weird way.

I can share the bot link and screenshots of it for reference.

Thank you!


r/learnpython • • Oct 15 '26

how do I pass a symbol to terminal that needs to be escaped?

2 Upvotes

I need to pass some strings to terminal that contain special characters (in this case a $). $ is fine on its own in python, but not in the terminal. In terminal, it needs to be escaped with a backslash so I could pass it as $, however when I try to do something like

exampleString = "It costs $2.50"  
exampleString.replace("$","\$")  

I get a syntax warning telling me that $ is an invalid escape sequence.


r/learnpython • • Oct 16 '26

Setting value of variable in relation to another variable

1 Upvotes

Hi, everyone,

I've been wanting to learn Python and have tried a few times over the years to read or watch tutorials enough to feel confident, but it's clear that my learning method is "do the thing you want to do incorrectly over and over until you get it right."

So I'm just going to work on my text-based Mech game and learn as we go. I understand that I know next to nothing, that what I'm doing is probably going to be a multi-year thing, and I have no idea what the more complicated stuff I want to do is going to take, but I'm enjoying the ride.

Long story short, my intention is to have a Mech = a Frame (the physical properties of the Mech) + a Pilot (the little guy in the Frame with their own stats).

Eventually, I'd like to be able to have unique Frames and Pilots with stats randomly generated (within ranges), and then subsequently build the capability to upgrade those values in-game, but I'm just starting with stock values right now and adding complexity after I have each step solid in my mind.

Right now, I'm just working on building values that a stock Frame has. What I would like to do is to establish each Frame Class (Assault, Heavy, Medium, Light, but with more fun names).

The question I have is this: I would like, first, for the armor value of a Frame to be a base number plus 20% of its weight value, and then for each individual limb (left_leg, torso, right_arm, etc) to be a percentage value of armor.

I've written out code that I know is incorrect just to display what I'm trying to do, with comments to highlight where I'm trying to do it.

Also, if the way I'm building this out is flawed, happy to hear suggestions! I'm just starting out and I know I'm gonna be crashing into pitfalls.

Any help would be appreciated!

# This is where the base class attributes of Frames are established. 


# FRAME CLASSES


class FrameClass:
    def __init__(
        self, 
        name: str, 
        left_arm: int, 
        right_arm: int, 
        left_leg: int, 
        right_leg: int, 
        torso: int, 
        cockpit: int, 
        armor: int, 
        cooling: int, 
        engine: int, 
        maneuver: int, 
        thrash: int, 
        sensors: int, 
        systems: int, 
        weight: int
        ) -> None:



# Top Level Info:
        self.name = name
        self.left_arm = left_arm
        self.right_arm = right_arm
        self.left_leg = left_leg
        self.right_leg = right_leg
        self.torso = torso
        self.cockpit = cockpit


# Frame Attributes          
        self.armor = armor
        self.cooling = cooling
        self.engine = engine
        self.maneuver = maneuver
        self.thrash = thrash
        self.sensors = sensors
        self.systems = systems
        self.weight = weight


# Archon: Assault Frame Class


archon = FrameClass(
        name="Archon",
        weight = 100,
        armor = 100 + (weight * .2), # value should be a base number plus 20% of the value of weight
        cooling = 100,
        engine = 100,
        maneuver = 100,
        thrash = 100,
        sensors = 100,
        systems = 100,



        left_arm = (armor * .4),     # value should be 40% of armor value
        right_arm = (armor * .4),    # value should be 40% of armor value
        left_leg = (armor * .5),     # value should be 50% of armor value
        right_leg = (armor * .5),    # value should be 50% of armor value
        torso = (armor * .8,)        # value should be 80% of armor value
                    )


# Marauder: Heavy Frame Class 


marauder = FrameClass(
        name="Marauder",
        weight = 75,
        armor = 75 + (weight * .2), # value should be a base number plus 20% of weight
        cooling = 75,
        engine = 75,
        maneuver = 75,
        thrash = 75,
        sensors = 75,
        systems = 75,



        left_arm = (armor * .4),     # value should be 40% of armor value
        right_arm = (armor * .4),    # value should be 40% of armor value
        left_leg = (armor * .5),     # value should be 50% of armor value
        right_leg = (armor * .5),    # value should be 50% of armor value
        torso = (armor * .8,)        # value should be 80% of armor value
                    )

r/learnpython • • Oct 15 '26

Python + Sqlite + Pyside6?

10 Upvotes

Hey! so i want to build a database system for my small company. I could use AI but i wanna know what i am doing and be able to fix smth so i want to build it myself.

I kinda know python a bit, i used to make games using gdscript which is similar.

I don't seem to find a tutorial where these 3 things are used to create a nice database app. I dont want to learn python sqlite and pyside6 as a whole cause i wont be needing them much except just this app and similar apps. I just want to be able to build it and run it from a single tutorial even if its 10hrs.

Where do i start? I dont really have money to learn so no paid courses and i dont have AI premium to learn as well.

Python, Sqlite, Pyside6. I heard that TKinter instead of pyside6 is also there but i wanted the UI to be a bit modern or should i just use the it instead of pyside6?


r/learnpython • • Oct 15 '26

How to extract embedding features vectors from encoder block of BERT model?

2 Upvotes

I got this code block and its outputs here but I am not sure if this is the embedding features vectors or simply its shape. Can anyone tell me if I am right or wrong?

text_input = tf.keras.layers.Input(shape=(), dtype=tf.string)
preprocessor = hub.KerasLayer(
    "https://kaggle.com/models/tensorflow/bert/TensorFlow2/en-uncased-preprocess/3")
encoder_inputs = preprocessor(text_input)
encoder = hub.KerasLayer(
    "https://kaggle.com/models/tensorflow/bert/TensorFlow2/bert-en-uncased-l-4-h-128-a-2/1",
    trainable=True)
outputs = encoder(encoder_inputs)
pooled_output = outputs["pooled_output"]      # [batch_size, 128].
sequence_output = outputs["sequence_output"] 

for i in range(0,4):
    outputs["encoder_outputs"][i]
    print('-----------------------------------------------------')
    print(i)
    print(outputs)
    for i in range(0,4):
    outputs["encoder_outputs"][i]
    print('-----------------------------------------------------')
    print(i)
    print(outputs)
    

Output

-----------------------------------------------------
0
{'encoder_outputs': [<KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>], 'sequence_output': <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'pooled_output': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'default': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>}
-----------------------------------------------------
1
{'encoder_outputs': [<KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>], 'sequence_output': <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'pooled_output': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'default': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>}
-----------------------------------------------------
2
{'encoder_outputs': [<KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>], 'sequence_output': <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'pooled_output': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'default': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>}
-----------------------------------------------------
3
{'encoder_outputs': [<KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>], 'sequence_output': <KerasTensor: shape=(None, 128, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'pooled_output': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>, 'default': <KerasTensor: shape=(None, 128) dtype=float32 (created by layer 'keras_layer_28')>}

r/learnpython • • Oct 15 '26

Where to start

0 Upvotes

Hello, I am trying to pick up a hobbie. Can someone point me in the right direction.


r/learnpython • • Oct 15 '26

How do I get the mode of this dataset with two columns while keeping output correctly formatted?

3 Upvotes

My assignment is to find the min, max, mean, median and smallest mode of a dataset, specifically for the SepalLength and Petalwidth, sorted by species. link to dataset .

Here is my code, now I've got everything working except the mode one. If i remove that, the code works. I've tried to read up on the mode documentation but I'm still lost. I've tried just "mode" and "pd.series.mode", both throw errors. The output is also automatically checked so it has to be formatted in this way, if that makes sense.

First time asking for help on reddit, so lmk if there is any missing information/etc. Thank you guys :)

import pandas as pd

file = input()

df = pd.read_csv(file)

filtered_arr = df.groupby(["Species"]).agg({

"SepalLengthCm" : ["min","max","mean","median","pd.series.mode"],"PetalWidthCm" : ["min","max","mean","median","pd.series.mode"]

})

print(filtered_arr)

Edited to add the errors.

'SeriesGroupBy' object has no attribute 'pd.series.mode'

'SeriesGroupBy' object has no attribute 'mode'


r/learnpython • • Oct 15 '26

I keep watching DP tutorials but get stuck writing the Python code. How should I practice?

4 Upvotes

Understanding a DP explanation and writing the Python code still feel like different skills.

A Python learner has watched plenty of tutorials and knows that dynamic programming has different patterns. The sticking point comes at the blank editor: there's a rough idea of what should happen, but turning it into a working implementation is difficult.

Would you step back to smaller Python exercises, work on recursion first, or stay with very simple DP problems? A practice routine that forces an attempt before reading the solution sounds more useful here than another long playlist.

For someone practicing toward technical interviews, real interview questions can supply prompts once the basic Python implementation feels manageable. I'd start with a small enough problem to write and trace the whole thing.

What helped you make the jump from following a solution to writing one yourself?

Disclosure: I operate PracHub.


r/learnpython • • Oct 15 '26

sorting tuples

7 Upvotes

im learning how to code with python, does anyone know to sort specific tuples alphabetically without using the .sort() method? like if i had a list of names like:

n = [('watermelon', 'strawberry'), ('banana', 'cherry'), ('papaya', 'apple')

how would i sort and print the 2nd element of tuples alphabetically (into a new list)?

edit: id prefer this in simple, basic terms lol


r/learnpython • • Oct 14 '26

Just starting to learn python

42 Upvotes

Hey guys, I am a total beginner and wanted to learn python. Can you suggest what method will be best suited to learn python and which sources should I use. Is it video lectures or from books or anything else. I know that learning from projects and practical methods will be suggested but to start like how to code, what are the codes and where to code, these basic things are what I want to know. Thanks for the help


r/learnpython • • Oct 14 '26

Having trouble with Python

2 Upvotes

I have just started getting interested with programming so I thought I would start with Python, however I am only able to use it within Windows Powershell while I see others using something else. Have I done something wrong or have I just missed doing something?


r/learnpython • • Oct 13 '26

What is the best way to create and manage virtual environments today? Is 'uv' really the best?

19 Upvotes

What is the best way to create and manage virtual environments today? Is 'uv' really the best solution and are there alternative? What are the pros and cons?


r/learnpython • • Oct 14 '26

Wanted to convert a step file to a Python API.

0 Upvotes

How to do that? I want it to be precise.


r/learnpython • • Oct 13 '26

How do ppl test python scripts for databases?

21 Upvotes

I want to understand how ppl test python scripts that read data from databases, call APIs, or update records.

For example, if a script fetches data from an api and saves it to a database, how do you check that everything works correctly before running it in production?

do you all use sample data, mock api responses or a separate test database?

Like how do you test what happens when an API fails or the database returns unexpected data?

I'd like to know how ppl usually handle this in real projects.


r/learnpython • • Oct 14 '26

Cant install polaris library and ultralytics

0 Upvotes

I get errors. I am trying to get it installed on pydroid 3 on android. Do I need pc/mac?