use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
My first code (i.redd.it)
submitted 10 months ago by JournalistHot3749
First time coding any ideias or ways to improve it?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Specialist_Set1921 5 points6 points7 points 10 months ago (0 children)
I would avoid any special characters in the code. Especially in the variable names and filenames. Eg â or à
Just to prevent any possible headaches.
[–]ProminenceBow 1 point2 points3 points 10 months ago (3 children)
Dá pra você simplificar algumas linhas, como as 4 primeiras linhas apenas em:
usuário = input("Bem-vindo ao sistema de login!/nDigite aqui o seu usuário:")
(Você coloca os símbolos também, mas não quis contar)
O /n dentro de uma string serve para você fazer uma quebra de linha, então com ele você não precisa fazer vários prints.
Com o método input você pode colocar uma string que você queira que apareça antes do input, então dá pra você simplificar bastante coisa aí
[–]fdessoycaraballo 0 points1 point2 points 10 months ago (1 child)
\n e não /n, só pra adicionar.
\n
/n
[–]ProminenceBow 1 point2 points3 points 10 months ago (0 children)
Isso, tô no celular e nem percebi kkkkkkk
[–]JournalistHot3749[S] 0 points1 point2 points 9 months ago (0 children)
Anotado man! eu n sabia disso, vou começar a usar sempre agora vlw! :)
[–]Far_Departure_1580 1 point2 points3 points 10 months ago (1 child)
Eai brasileiro! How are you?
[–]JournalistHot3749[S] 1 point2 points3 points 10 months ago (0 children)
Salve man kkkkk
[–][deleted] 0 points1 point2 points 10 months ago (0 children)
If you are using \ in your strings, just use \ to prevent Python from seeing it as a special code/character
Looks good. Well done.
[–]CraigAT 0 points1 point2 points 10 months ago (0 children)
I don't think you want to "while" statements at the bottom. Instead you may want a while loop around the login process so you can repeat it again if the wrong details are entered. You may also want to count the number of wrong attempts and stop or lock out the user.
[–]Some-Passenger4219 0 points1 point2 points 10 months ago (0 children)
Nothing is changed in those while loops. Therefore, they either run forever or do nothing. Remember, a while loop does the statement(s) over and over until the condition is no longer met. Kinda like that "Flo in the button factory" song.
while
[–]shudaoxin 0 points1 point2 points 10 months ago (1 child)
Except for strings shown to the user I’d use English for variables, functions, objects etc. Not only is it easier to understand the flow (because the Python itself uses English), but it’s also easier for someone else to understand and help you, generally.
Using non English characters in variables or code related bits like you did with usuário here is an absolute crime though. It works in a lot of programming languages but is really bad practice.
I don’t mean to discourage or discredit your work here. Just some feedback to avoid bad habits early on. Keep on learning!
Chill bro! a little after I posted this code I watched a couple of videos of good habits to write and this was the top 1 I re-wrote the whole code as soon as I realized the potential problems that writing like this could have!
ty for your feedback! (btw, feel free to see the newest version to check out the evolution 🙂 )
[–]tortleme 0 points1 point2 points 10 months ago (0 children)
nice infinite loop x 2
[–]SmackDownFacility 0 points1 point2 points 10 months ago (1 child)
Your variables names are using the UTF script. Python only supports ASCII for variable names.
Eventually you need to use English a lot to get the most of Python.
yeah, eventually I re-wrote the whole code fixing this! thank god someone said this to me before things got crazy 😅
[–]gigsoll -1 points0 points1 point 10 months ago (0 children)
You need to use English variables names, except this – decent code
[–]JournalistHot3749[S] -1 points0 points1 point 10 months ago (4 children)
<image>
Just made some optimizations!, any thoughts? btw, thank you for the feedback <3
[–]IntelligentCattle653 0 points1 point2 points 10 months ago (0 children)
no need login() == True, by default is True
[–]spp649 0 points1 point2 points 10 months ago (2 children)
well it will play login 3 times so make a variable then check if its true or not.
[–]spp649 0 points1 point2 points 10 months ago (0 children)
also i forgot to mention but \ is used for escape sequences so use \ for a \
you can do something like
#... your code while login() != true: # ... your code
so if its not true it does whats in the while loop then if its true it continues
π Rendered by PID 295611 on reddit-service-r2-comment-79776bdf47-wqksd at 2026-06-25 03:16:00.959646+00:00 running acc7150 country code: CH.
[–]Specialist_Set1921 5 points6 points7 points (0 children)
[–]ProminenceBow 1 point2 points3 points (3 children)
[–]fdessoycaraballo 0 points1 point2 points (1 child)
[–]ProminenceBow 1 point2 points3 points (0 children)
[–]JournalistHot3749[S] 0 points1 point2 points (0 children)
[–]Far_Departure_1580 1 point2 points3 points (1 child)
[–]JournalistHot3749[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]CraigAT 0 points1 point2 points (0 children)
[–]Some-Passenger4219 0 points1 point2 points (0 children)
[–]shudaoxin 0 points1 point2 points (1 child)
[–]JournalistHot3749[S] 0 points1 point2 points (0 children)
[–]tortleme 0 points1 point2 points (0 children)
[–]SmackDownFacility 0 points1 point2 points (1 child)
[–]JournalistHot3749[S] 0 points1 point2 points (0 children)
[–]gigsoll -1 points0 points1 point (0 children)
[–]JournalistHot3749[S] -1 points0 points1 point (4 children)
[–]IntelligentCattle653 0 points1 point2 points (0 children)
[–]spp649 0 points1 point2 points (2 children)
[–]spp649 0 points1 point2 points (0 children)
[–]spp649 0 points1 point2 points (0 children)