Return...return... python diary #4

2018-12-07T00:45:54
returnreturn.jpeg/
Dear Diary,
I'm back :D Who would have thought that a cold at the end of October would lead to a surgery last week? I certainly didn't. Now I'm sitting at home with a tissue to stop a nosebleed. It's surreal. But now there is time to continue learning, and see how much had settled in my head.
Of course, the best way to check that would be to do one of the edX tasks... since they often omit some explanations and you have to do some guesswork/head scratching ^^;
Since I've started the conditionals and learned more syntax, the task reflects that as well and works as a brush up for some function stuff... Conditionals are quite easy to understand so far :D The problem of course again lies in the fact that I don't know functions very well yet.

 Where do you use/add return inside a function with conditionals?

First I tried to write it like this (as per previous conditionals examples on edx):


Buuuut... yeah.... since I didn't add a return anywhere, the function returns None. 
I tried to add it here and there for a while to see how it would go, but after giving up and googling the answer turned out to be a lot more trivial... Wha??? Is that where you stick <strmore: turn? Pretty anticlimactic, (-_-;) and sort of enlightening. Ha! I should play around more :B

Things that I learned about functions (and then noticed some more mistakes) this time are:
  1. The function above has a ton of mistakes in it xD
  2. You can use one of the parameters inside the input (omg! why didn't I think of it myself and nobody told me?? :D)
  3. Return works with strings without any extra blings around it (ohohohohoh)
  4. Functions can do something or give out a result.
  5. Don't use weird names for codes like deku_quiz.
  6. Codeacademy has better explanations than edX. edX is better for playing around blind and learning how to swim.
*image source Boku no Hero Academia.

Any other tips or fun tasks with functions are appreciated :D huhuhu

(Of course, I made more mistakes than I thought and thanks to Andikki <3 I found most of them)
30
9
4.54
9 Replies