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.
Challenge: Port the code - Python Tutorial
From the course: Python for JavaScript Developers
Challenge: Port the code
(upbeat music) - [Instructor] Porting some JavaScript code into Python may really help solidify some of these concepts. So here I am in 02_06.JS, and there's a simple program we're going to port into Python in this challenge. So in the first three lines, we define some constants the first one being a string and then a number followed by some items. Then there's a function that takes a user, credits, and items, and it interprets a string using the first item in the index zero, then the user, then the credits. Finally I console log this function being called with my username, credits, and items in the cart. So here at 02_06.PY, you'll see that I've put in some boiler plate for you to write your code in. So I've created the structure of a plain function and go ahead and put those definitions and the functions followed by a print statement in order to print out the output. And I'll see you in the next video for the solution.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.