Dear Diary,
Today I finally sort of figured out two things that bothered me in the course I'm taking.
When the functions were introduced, the parameters would be interchangeably called variables or values. That was confusing because they didn't explain that the parameters are indeed variables 馃槅
---- solved by checking it out on Code Academy, where they explain it plain and simple. I suppose it could be just in Python and other languages might distinguish between a parameter and a variable in a more stricter way.
One of the tasks had me scratching my head again, when they asked to make a function and call another function from a previous task.
Mind blown... you can do that? Nice!
But how?
---- After several unsuccessful attempts, I went back to the Code Academy. Where they also show how it's done, sort of.
# [ ] define title_it_rtn() which returns a titled string instead of printing
# [ ] call title_it_rtn() using input for the string argumetnt and print the result
def title_it_rtn(book):
book = book_entry.title()
return book
book_entry = input("Input book title here: ")
print("This is the book title I've mentioned before: " + title_it_rtn(book_entry))
The above part where they ask to call title_it_rtn() with book parameter, is very confusing.
# [ ] create, call and test bookstore() function
def bookstore(book, price):
example_output = "Title: " + title_it_rtn(book) + ", costs $" + price
return example_output
price_entry = input("input Price: ")
print(bookstore(book_entry,price_entry))
Now that still makes me puzzled somewhat since it doesn't exactly do what the task is asking for.
But when I tried getting a separate book input just for the bookstore() it would keep printing whatever I input in the title_it_rtn() earlier (understandably).
taken from Module 2 Practice - notebook 3 of the edx course.
~ Anmitsu