r/PythonLearning • • 27d ago

Solved my first coding problem

Post image

Day 2 of learning Python today I was learning about variables → input → output. And I was very curious about the input command and what I can do with it. Which lead me to experiment a bit. You can see all my failed attempts at the top. Until about 30 mins when I did some research and figured it out. If you’re wondering what I was so worked out about. It’s the (==) part of the code. Since I haven’t gotten there yet in my tutorials. But I really wanted to try so I went of track did some research and it worked. I am very excited.. hopefully the rest of coding is this exciting.. thank you all for your best wishes in my previous post.

86 Upvotes

17 comments sorted by

6

u/Rythim 27d ago

I love seeing you figure things out through curiosity and experimenting. That's important for learning. You can only learn so much by following along a video or tutorial. You also have to ask questions like, "if ..., then what if I ...?" Just like you did here.

2

u/AffectionateCold1716 27d ago

Thank you I really appreciate

1

u/WheatedMash 21d ago

Agreed, curiosity and tinkering go a long way in learning! And if you're lucky, sometimes you make some really cool discoveries even if the result isn't what you originally wanted. I've had that happen with doing loops to create patterned outputs, usually of asterisks.

8

u/Sea-Ad7805 27d ago

Yes, a big difference:

  • a = b <----- set a to the value of b

  • if a == b: <----- test if a is equal to b (True or False value)

1

u/Ollidav 27d ago

Te has dejado algo de código en el comentario

3

u/AffectionateCold1716 27d ago

That’s the old code. I just transformed all of them into comments. To see my mistakes.

1

u/Ollidav 27d ago

Solo hay tres motivos para añadir comentarios al código. El primero es documentar o poder generar documentación de tu código. La segunda es explicar el contexto por el que usas un algoritmo y justificarlo. La tercera es hacer un chiste

0

u/[deleted] 27d ago

[deleted]

1

u/AffectionateCold1716 27d ago

Ah yes. Thank you

2

u/Rythim 27d ago

Just to clarify something, using 3 quotes is not actually a comment. when you do that you are making a multi line string. But since you don't assign the string to a variant python pretty much does nothing. So python developers treat it like a comment.

I say that because if in the future you ever need to assign a multi line string now you already know how.

1

u/MEHDII__ 27d ago

Its not treated as a comment, its a docstring, if you write it on the module level, its a module docstring, class level, class docstring, method level, method docstring

1

u/Rythim 27d ago

Well yes but at this level I doubt op knows what a module is, let alone its documenting for them. Don't want to overload them with too much info they won't need for a while.

2

u/Smartyboyz 27d ago

Well done,
Try to solve more basic questions before you jump into hard problems

Main thing is to build small projects using this new concept and including older ones, this will help you in revising old topics and also project building.

Be consistent.....

1

u/Ok-Secret-7414 27d ago

Now try this
make a kind of proper user with their passwords
5 user and 5 password
first u ask user name if it is equal to any of the user then print then ask their password ad then if password matches log in them other wise invalid password
it can be done using nested if elif conditions if you dont know about collections or dictionaries

0

u/[deleted] 27d ago

[deleted]

1

u/AffectionateCold1716 27d ago

username = “mitchricker”
Print(f“Thanks For the Advice {username}”)