[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

I've been learning Python for a few days, made my first

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 8
Thread images: 2

File: “Gluten-Free-Ebola”.jpg (155KB, 1470x768px) Image search: [Google]
“Gluten-Free-Ebola”.jpg
155KB, 1470x768px
I've been learning Python for a few days, made my first program. It's simple and stupid but It's a step. Can anyone scrutinize this and give me some noob tips?

<code>print('Welcome to Hell!')

def gamename():
print("You are standing In a hallway thinking.... You want to move \n but where to? Left, right, up or down?")
answer = input()
if answer == 'left' or 'Left':
print('You move to your left and see a knife, you trip \n being the dumb weeaboo you are, puncturing your torse enjoy death.')
gamename()
elif answer == 'right' or "Right":
print('You turn to your right with movement, triggering a landmine, you must be bad at life huh?')
gamename()
elif answer == 'up'or 'Up':
print('You jump, that seems useless In a hallway, please re evaluate your life')
gamename()
elif answer == 'down'or 'Down':
print('You sit down on your dragon dildo, nice job faggot')
gamename()
elif answer != 'left'or 'Left' or 'up' or 'Up' or 'down' or 'Down'or 'right' or 'Right':
print('PICK AGAIN')
gamename()

gamename()


</code>
>>
Also If one of you could give me the hidden knowledge of how to format code on here like everyone else I'd be happier than a gay at a circle jerk.
>>
Bait, right?
>>
>>55662593
>>>/v/eddit
>>
>>55662593
you should represent u/d/r/l as 1 2 3 4 then explain that to the user so they don't have to type in an actual direction.

and your conditionals are all fucked.

 answer == 'right' or "Right' 
will always be true.

you're evaluating if answer is the inputted string is 'right' but your second expression isn't testing anything, it's just a string, which will always be true.


it should be
answer == 'right' or answer == 'Right'
>>
>>55662593
You're calling your function recursively in every branch of your if-else block. If it always has to execute, put it after your if-else block. Also, if you just want to start from the top of your function again you don't need recursion, it unnecessarily blows up the call stack. What you want is a neverending loop with
while True
>>
>>55662593
I have a fealing i am just talking to a master baiter but fuck it.
You should just convert the users input to lower case then check the lower case version of each word against the input. Then all you have to write is "if answer == "left"" instead of what you have there. Also like the other anon said "if answer == "left" or "Left"" will always evaluate True.
>>
File: 1468953024722.png (360KB, 600x590px) Image search: [Google]
1468953024722.png
360KB, 600x590px
>>55662593
Thread posts: 8
Thread images: 2


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.