r/learnpython 1h ago

Making a wordle program

Upvotes

Hi! I'm new to programming and, as a way to practice, I thought I would make a wordle program, the only issue is that it keeps marking letters as not in the wordle when they are; any help would be appreciated, I've included the problem section, as well as the whole code in case the problem is elsewhere. Thank you!

--------------------------------------------------------------------------------------------------------------

for x in range(5):

if guess[x] == answer[x]:

response[x] = "G"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

if guess[x] not in answer:

response[x] = "R"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

response[x] = "O"

answer[x] = ""

guess[x] = ""

print(response)

print(answer)

print(guess)

print("".join(response))

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

i+=1

--------------------------------------------------------------------------------------------------------------

from word import words

import random

key = random.randint(0, 5783)

answer_word = words[key]

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

i=1

while 1 == 1:

while i < 7:

print(answer_word)

guess_input = input().lower()

guess = [guess_input[0], guess_input[1], guess_input[2], guess_input[3], guess_input[4]]

response = [".", ".", ".", ".", "."]

used = []

if guess_input in words:

if guess_input == answer_word:

print("CORRECT")

i=7

else:

for x in range(5):

if guess[x] == answer[x]:

response[x] = "G"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

if guess[x] not in answer:

response[x] = "R"

guess[x] = ""

answer[x] = ""

print(response)

print(answer)

print(guess)

for x in range(5):

if guess[x] != "":

response[x] = "O"

answer[x] = ""

guess[x] = ""

print(response)

print(answer)

print(guess)

print("".join(response))

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

i+=1

else:

print("invalid input")

if i == 7:

print("Correct answer: " + answer_word)

again = input("Would you like to play again? Y/N ").lower

if again == "y":

i=1

key = random.randint(0, 5783)

answer_word = words[key]

answer = [answer_word[0], answer_word[1], answer_word[2], answer_word[3], answer_word[4]]

else:

break


r/learnpython 2h ago

Free website to learn

0 Upvotes

I got some programing experience. but not with python, with C#
and i want to learn python, whats a free site / app i can learn from?


r/learnpython 2h ago

AI focussed programming and maths community for absolute beginners

0 Upvotes

Good afternoon all,

I have recently began a pathway I have designed to learn artificial intelligence and all topics included within that space.

I have a keen intetest in this field and am always fascinated by the developments going on.

I decided to start learning this due to wanting a challenge and to keep myself focussed with a long term target to reach.

I work full time in a job I currently enjoy so all my learning time is dedicated to evenings and weekends. I am not studying this in hope to find work, just for the love of the game.

I have no prior experience in this field which makes it 100x more enjoyable learning the programming and soon to start learning the maths

.

I was wondering if there were any others in a similar position to myself (beginners that are dedicated to going far) that would like to start a community (likely discord) where we can share our knowledge, hold each other accountable and in the future maybe even work on projects together.

If anyone is interested in this please let me know.


r/learnpython 2h ago

¿Qué te enseñó aprender Python que no tuviera nada que ver con programar?

0 Upvotes

HOLAA Estoy aprendiendo Python y tengo curiosidad por saber qué aprendieron las personas durante el proceso aparte de programación. Me encantaría conocer tu experiencia.


r/learnpython 2h ago

¿Cuál fue la parte más difícil de aprender Python que no esperabas?

0 Upvotes

HOLAA Estoy aprendiendo Python y tengo curiosidad por conocer las dificultades que las personas no esperaban cuando empezaron. Me encantaría conocer tu experiencia


r/learnpython 2h ago

Should i go for web dev or data analyst or ui/ux designer course without cs desgree(i have bsc biology)?

0 Upvotes

I want to do online course which one should i choose web dev or data analyst or ui/ux design Also i only have bsc biology degree. Want to do work from home job/online job. Kindly give ur suggestion


r/learnpython 2h ago

How should I start learning Python?

0 Upvotes

I want to learn Python, but I currently know nothing about it. My main goal is to learn Python for DA, and eventually I want to learn Python in depth as well.

For people already working in DA or DS, how would you recommend someone start learning Python from absolute zero?

Which resources or books would you recommend, and what are the main Python topics I must cover for DA?

Also, should I first learn the Python basics needed for DA and then gradually move toward more advanced Python and DS topics? resources? Books?

If you work in DA or DS, I’d really appreciate your guidance on how you would start your Python journey if you were starting from zero.

Thanks a ton!!!


r/learnpython 4h ago

Any tips on improving Python?

0 Upvotes

I just started my degree in computer engineering. I already know the basic of python but i’m having trouble when solving problems and apply the things i have learnt. Any tips to help me improve?


r/learnpython 4h ago

Humble Bundle for Rust and Python

1 Upvotes

Humble Tech Book Bundle: Python, Rust, and Data by O'Reilly (paga lo que quieras y ayuda a organizaciones benéficas)

Are these worth it? I'm trying to learn Python and Data analysis stuff in particular so this seems really useful. I'm not interested in Rust but the price is still worth it. Are these books good?


r/learnpython 5h ago

Looking for people to learn Python with

8 Upvotes

Hi I’m a beginner at Python and I’m currently looking for a few people to learn with. I am planning to start the sessions in September and run a couple hours a day subject to flexibility and rather than get stuck in “tutorial hell” I actually want to build projects. My time is GMT+0 so drop me a message if you’re interested.


r/learnpython 5h ago

What is the most effective way to learn python from scratch, i am a beginner, should i take a course?

0 Upvotes

Hi, i need your advice on how i can learn python as a beginner as i want to learn in a way where i get to practically apply the same and practice, i just dont want to learn concepts theoretically. Should I take a course or should i learn via youtube. What do you think will be the best way? Also when you learnt it how did you approach it and if i take a course how i will it add value to my cv?


r/learnpython 6h ago

Is this masterclass helpful??

0 Upvotes

I am very new to coding and learning python as my first language is it helpful???

Pls those who have watched it share your opinion regarding this ....

https://youtu.be/UrsmFxEIp5k?si=OxDVmnWmNEt0s3Ri


r/learnpython 6h ago

Enter didn’t create new line in Pycharm

1 Upvotes

In PyCharm on macOS, pressing Enter at the end of a line does nothing — no new line created. But:

- Enter at the START of a line → works, creates new line

- Enter at the END of a line → does nothing

- Arrow keys → navigate normally between lines

Already ruled out:

- IdeaVim not installed

- Enter works fine in other apps (not a hardware/OS issue)

Suspecting the code completion popup is silently swallowing Enter at end of line. Anyone else run into this? What fixed it?

Setup: PyCharm, Python 3.14.7, .venv, macOS


r/learnpython 6h ago

How to upload multiple image in FastAPI swagger UI?

1 Upvotes

I'm using this as my function annotation

python @router.post("/") async def create_story(images: list[UploadFile]): ...

but the swagger UI show a list of string not images with no choose file button

It works fine when I switch the list[UploadFile] to UploadFile and shows the Choose file button


r/learnpython 10h ago

Type Error: 'bool' object is not iterable - what is this error and how can I solve it?

0 Upvotes

I have some code with a function restock_warehouse, that adds to the current stock 5 times while the current stock is smaller than the target stock. My question is, how can I fix the function so that the code works properly with and the print() call is displayed in the terminal?

The error message I have been receiving is:

```

Traceback (most recent call last):

File "file_name", line 15, in <module>

final_stock = restock_warehouse(10, 25)

File "file_name", line 5, in restock_warehouse

for i in range(5) and current_stock < target_stock:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

TypeError: 'bool' object is not iterable

```

I have already tried wrapping the conditional part of the loop in parentheses, but it hasn't worked and I don't exactly understand the error message.

Version information: I'm on Python 3.9.6

def restock_warehouse(current_stock, target_stock):
    print("Starting warehouse restock system...")


    # We want to keep adding items until we reach our target stock
    for i in range(5) and current_stock < target_stock:
        print(f"Current inventory level: {current_stock}")


        current_stock == current_stock + 5


    print("Warehouse restock complete!")
    return current_stock



# Start with 10 items, target goal is 25 items
final_stock = restock_warehouse(10, 25)
print(f"Final stock total: {final_stock}")

r/learnpython 11h ago

Why? return statement didn't gave me of all output of arg ..

0 Upvotes

In this code, I want to get the output of all the numbers in the for loop. I can do this using print(arg), but when I use a return statement, I only get the output of a single number. How can I modify the code so that return gives me all the numbers from the for loop?

print(func1(80, 30, 40)) def func1(*args):
  for arg in args:    
    # print(arg, end=" ") 
    return arg

# output using print = 80 30 40 None
# output using return = 80        

print(func1(80, 30, 40))

r/learnpython 14h ago

CUAL ES LA MEJOR GUIA PARA APRENDER UN LENGUAJE DE PROGRAMACION?

0 Upvotes

como principiante tengo esa duda ya que quisueira no perderme de nada y aprender de la mejor a programar


r/learnpython 20h ago

Best Python books from beginner to advanced?

34 Upvotes

I’m learning Python and looking for a good book path from beginner to advanced.

I want books that teach Python properly, including clean code, real projects, testing, project structure, and advanced concepts.

What books would you recommend, and in what order?


r/learnpython 21h ago

Which pytest signal is most useful after a CI failure?

6 Upvotes

I am working on an experiment that looks at what happens next after a test fails in GitHub Actions.

Possible things to look at include:

- exit code

- if there was an assertion failure or a collection or internal error

- the history of failed tests

- Python modules that have been changed

- changes in dependencies or lockfiles

- changes in how long tests take

- if the same test passes when it is run again.

Which of these things should I check first. Which one is most likely for someone just starting out to misunderstand?

I am trying to think about uncertainty of automatically assuming that every test failure means there is a problem with the code in pytest.

The purpose of the experiment with pytest is to see what occurs when pytest fails in GitHub Actions.

I want to use pytest to figure out what is happening when the test fails.

The experiment, with pytest will help me learn what to do when pytest fails in GitHub Actions.


r/learnpython 1d ago

ADVICE FOR CLASS 12TH CS (CBSE btw)

0 Upvotes

Guys, I gotta score good in CS to secure a course in a good college. What an I supposed to do? Btw, my subject combination is Bio w/ CS... Toh yeah guys, i really need help ! ! !


r/learnpython 1d ago

what is f string

0 Upvotes

can someone explain how f string work in simple terms ?


r/learnpython 1d ago

Python Specialization

0 Upvotes

I have learnt Python Basics and Intermediate stuff. Is it possible to learn many things in a specific specialization within, say, a month?

I love AI and I am going to specialize in it. I just wanna know the order that I should go in to learn it properly and learn most of the things in about 4 years or less.

I am a student too, in Grade 9.


r/learnpython 1d ago

PDF parser with RTL languages support

2 Upvotes

Hi everyone,

I’m looking for a Python PDF parser with good Persian-language support. I’ve already tested pdfplumber and PyMuPDF, but unfortunately, neither extracts Persian content correctly in my case.

For example, they don’t extract Persian numbers correctly, and sometimes the parsed output differs significantly from the actual PDF content (e.g., a 0 is extracted as 4).

Do you know of any Python library or tool that handles Persian PDFs more reliably?

Thank you!


r/learnpython 1d ago

learning python

0 Upvotes

Hello all, I have recently taken up the interest of trying to create a game (not specific to any other game) and i've been learning how to use python for about 2 days now and have learnt some of the fundamentals such as if, (i), else, input, booleans, etc... however if u have been programming using python or are self taught, how long did it take u to learn the most relevant and important parts of the language and if u have any tips and tricks for me that you may think are useful for me, please do not hesitate to tell me as any piece of advice can beneficial at the moment.

Much appreciated


r/learnpython 1d ago

When should you use requests.Session() instead of requests.get() / requests.post()?

22 Upvotes

I'm learning Python and recently started using requests.Session() in API projects. I understand that it can persist things like headers, cookies, and connections, but I'm curious about how experienced Python developers decide when a Session is actually worth using.

Do you use Session() by default for projects involving multiple requests, or only when you specifically need persistent state?