Welcome to the Treehouse Community
Looking to learn something new?
My code looks completely different (shorter, works okey), but is it right?
Hi everyone! In this code workshop Kenneth offer to pause the video and try to code all by yourself. And, well, and I've done it (don't blame it, it's up to Kenneth). I've done the script, which was described in the video:
def shopping_list(): your_product_list =  while True: product = input("Please, add a product to your shopping list. If you want to finish, simpy type DONE: ") if product == "DONE": break your_product_list += [product] print(your_product_list) shopping_list()
First of all, it really works (God bless Treehouse!). And it's rather shot.
After this I've watched Kenneth's video and was shocked. His code looks nice and logic, but it extremely differs from my approach. So the question is: is my code okey or I miss something?
P.S. Just for information: I'm not crazy A-sicker, I just afraid that I could misunderstand some of the key concepts of Python. Will appreciate any advice.
Steven Parker215,958 Points
Other than the comments, your code looks much like the video. You used the append operator (
+=) instead of the append method, but the job done is the same.
The more complex a program gets, the more ways there are to accomplish the same goal. You can expect to see this more and more as you progress.