Skip to main content

r/learnpython



Advertisement: We know you want to expand your business. Advice from Shopify on global growth is a swipe away.
We know you want to expand your business. Advice from Shopify on global growth is a swipe away.
  • We know you want to expand your business. Advice from Shopify on global growth is a swipe away.
  • We know you want to expand your business. Advice from Shopify on global growth is a swipe away.
  • We know you want to expand your business. Advice from Shopify on global growth is a swipe away.
  • We know you want to expand your business. Advice from Shopify on global growth is a swipe away.
  • We know you want to expand your business. Advice from Shopify on global growth is a swipe away.


Learning Python at 37 and I can read code fine but can't write 10 lines without the lesson open
Learning Python at 37 and I can read code fine but can't write 10 lines without the lesson open

37, learning Python in the evenings for about 3 months. I can read other people's code and follow every lesson, but the moment I close the lesson and try to write something small on my own, like a script to rename my photos, I'm stuck after a few lines. I did a free intro course before this and hit the same wall, so this time I'm paying for something structured. What made writing code on your own start to click?


Turning 19 boolean variables into 1.
Turning 19 boolean variables into 1.

I'm back again, hopefully with clearer information.

I have 19 boolean variables. Each one is labeled with the date of an election. Inside the variable has true/false. True is voted, False is didn't vote.

I want to create a voting history variable that has a few options.

Never voted, if all 19 are false.

Voted in the past 5 years, if any of the date variables in the past 5 years, aside from the recent midterm, have a vote.

Voted in the past 10 years, if no votes were cast in the past 5 but there were votes in the past 10.

And recently registered, which would involve the registration_dt variable which I feel more confident being able to implement.

Here is my code & the data.

I just really don't know how to turn these into one variable without losing information. Thanks so much :)