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!
Next |
---|
Daily and Fresh π· #237 |
Daily and Fresh π· #238 |
Daily and Fresh π· #239 |
Daily and Fresh π· #240 |
Daily and Fresh π· #241 |
Previous |
---|
Daily and Fresh π· #235 |
Daily and Fresh π· #234 |
Daily and Fresh π· #233 |
Daily and Fresh π· #232 |
Daily and Fresh π· #231 |
Weeklies |
---|
Weekly and Fresh πΈ #33 |
Weekly and Fresh πΈ #32 |
Weekly and Fresh πΈ #31 |
Weekly and Fresh πΈ #30 |
Weekly and Fresh πΈ #29 |