Choose your adventure in Python

I woke up this morning and couldn’t wait to get started on my #python for #100DaysOfCode. I was itching to get started. Had a continuation idea from the night before of adding to a global variable and depending upon that value, having different loops run.

This threw me for a loop and I could barely function. Get it? Loops? Functions?

I know it’s ugly. Took me a bit to learn that only had to declare global variable once in a function.

But, moving forward, my idea is that a T-Intersection is t_intersection() and would run a function of ‘choose left or right’ whereas a four-way intersection might be four_way() and offer left/right/straight.

I’m not sure how to pull this off. My head tells me that the code is run from top to bottom. But my gut tells me that all root levels are equally important and can run in any order. Obviously I am mistaken, or to be more accurate, I don’t fully grok how code relates to itself.

The output of this is pretty ugly. Spaces, indents, and more problems. Plus, if one just doesn’t play, with the first question of opening the gate or not, if you select no, it displays the right string afterward, but also an error because my block variable is a 0, and the while loop at the bottom needs something for that.

https://repl.it/@eddiecoyote/ChooseYourPath#main.py

Published by Eddie

I'm a goofball. I like Doctor Who, Star Wars (yes, all of them), and of course Firefly. I think that "Out of Gas" from Firefly is the single greatest episode of any SciFi. Closely followed by "All Great Things..." from Star Trek: The Next Generation. I'm an Apple geek. Seriously, I brought a 2013 MBP and two iPads with me on deployment. Every year I watch all the Apple Keynotes. Someday I'd like to learn Swift, as I've got some ideas for some useful apps that I'd like to use. One might find me at a coffee shop, at the LGS getting more Magic: The Gathering cards, on some trail in the mountains of Oregon, on one of my Macs, running a trail, or who knows.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: