From the course: Python for JavaScript Developers

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Porting the greeting

Solution: Porting the greeting - Python Tutorial

From the course: Python for JavaScript Developers

Start my 1-month free trial

Solution: Porting the greeting

(upbeat electronic music) - [Instructor] So our goal for this challenge was to once again port a program into Python from JavaScript. And here we are in 03_06 in our exercise files with a solution. Now, by the way, the names that I chose for this exercise were names of comedians in the Monty Python comedy troupe, after whom the Python language is named. Just a fun fact. So on line one, I define a list of Python dictionaries called FRIENDS. I use all caps because it's a constant. And you'll see that each dictionary has a key, which is a string. This is different in Python than it is perhaps in a JavaScript object. And then on line 11, I start an iteration over the friends, and for each friend, I check if A is in the friend's name. And I use a lookup that's a string within a bracket. Then on line 13, I print out an interpolated string where I embed the friend's name after a short greeting. So hopefully these…

Contents