Unproductivity :: Daily and Fresh πŸ“· (236/366)

in Daily & Fresh πŸ“Έ β€’ 4 years ago (edited)

Hey!

Today wasn't particularly productive when it comes to photography...

And this photo is more like a reminder for myself to do something with my gear.

I've been doing Python excercises instead.

One such exercise told me to write up a code that would print only the even characters from a string.

I think I thought about it too much because I messed up the code:

string = "tomppeli"
print(tomppeli[::2])

Of course that didn't work and returned:

Traceback (most recent call last):
  File "tomppeli.py", line 2, in <module>
    print(tomppeli[::2])
NameError: name 'tomppeli' is not defined

When I searched around for a solution, I ended up finding the exact solution to the problem, but also realized that I had been an idiot, a "tomppeli" myself. I had simply used the string as the name of the string and that was what broke the code.

Corrected code goes like this:

string = "tomppeli"
print(string[::2])

And that will print out: tmpl. As it should.

Well... we learn something every day.

But I guess I will do a pong game next. I cheated a bit and watched a video where someone showed how to code it. It looked like a surprisingly easy one. But I don't know if I want to use the turtle module. I'll try making it in pygame instead.

But that will have to wait until tomorrow. I've got a bit of a back ache so...

See ya!




Like my post? 🍻 Buy me a beer! 🍻

Sort: Β 

The gear you used for photography is very useful and it alwalys gives you the moment that you work hard for it, your daily and fresh is now seems like a brand for the community. You have represents some beautiful and unique moments, now you have engaged with some coding projects.