Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialkhai ellington
Courses Plus Student 834 Pointsim unsure what to do here.....am i supposed to give the command to print the formatted string??? ive tried everything...
ive done exactly what the question asks in python, and it works. however my answer is not accepted in the quiz. am i supposed to command to print, or just enter the .format command alone??
name="khai"
subject="Treehouse_loves {}"
'.format(name)
4 Answers
Matthew Porter
3,892 Pointsshould look more like this. you are close but added some extra characters
name="khai"
subject="Treehouse_loves {}".format(name)
khai ellington
Courses Plus Student 834 Pointsi see. I guess im abit confused because i dont quite know what strings are used for......it seems silly to need the formating command right behind the syntax.......why wouldnt i just input the desired name???.........im a super noob, just picked this up yesterday, but this question was really confusing. it just seemed very counter intuitive and redundant
Jennifer Nordell
Treehouse TeacherWell let's suppose you have a website. And everyone that logs in to your website gets a "Profile" icon with their name. But maybe it doesn't end there. Maybe we use their name several times in email messages, ads/promotions etc. It's much easier to store that user's name as a string in a variable and then just use the variable over and over. Otherwise you're going to have to write out that user's name in your code repeatedly... and for each separate user. Remember, we're trying to make the computer do the work for us! Really great programmers are inherently lazy. We want our code to do as much of the work as possible with the least amount of typing. In fact, later on, you'll learn about a concept known as "DRY" which stands for "Don't Repeat Yourself".
Hope this helps!
khai ellington
Courses Plus Student 834 PointsI think I understand......so when you want to change these automated parameters, you edit the "name" definition.....and that second line is the "command" to insert the value of "name" into every instance the subject line is used.....
as a side comment on the lesson itself, I think I would better grasp these preliminary lessons if I understood the basic function of the command interface......what do lines represent? are they read by the operating system in descending order?? what is a strings function?? am i just typing words as notes or are these "strings" the code/commands for a system to operate from???? certainly these questions will be answered in the course, but perhaps they should be up front??
Jennifer Nordell
Treehouse TeacherTo further clarify, this is programming. This is not about a command line, although you can make programs to run at the command line. These programs will be built/compiled later by the compiler/interpreter. It takes your code and makes it into commands the machine can understand.
Think about this for a moment. What command do you type to start an app on your smart phone? You don't, do you? You simply click on a button and an app launches and you do whatever you need to do in that app. To be clear, Python isn't really meant for mobile development, but I'm just using mobile devices as an example.
I think part of the problem here lies in understanding what programming is at its root. My advice is before continuing down the Python track you do the entirety of the Digital Literacy track. It's a great intro into how computers and the internet work and also what programming is, why we do it, and a bit about some different languages available to learn. I feel like your learning experience will be better overall if you understand a little more clearly what you're trying to achieve. It's always easier to hit a well-defined goal!
Matthew Porter
3,892 Pointsin a larger system the 'name' object would get its value from another input or source and would then change what gets formatted into a string. Like if your phone had a 'name' for you and it gave you custom messages when something happened, but then someone elses phone would use their name instead of yours.
khai ellington
Courses Plus Student 834 Pointsahhh yes, I agree, my basic knowledge of computer architecture is too minimal to learn optimally. Thank you so much for clarifying!! I have to say the support here on this site is superb, and I cannot wait to learn more.
Last question, on the topic of goal definition:
I am an industrial designer and mechanical engineer working with several product development teams across a wide range of products. I recently got involved in a GPS tracking device for emergrncy first responders which features several sensor units that interact with an web based app. I reached a point in the design where I need to dive into hardware functionality, and interface navigation, so i picked up an Arduino and Raspberry pi as a prototyping tool (instantly hooked).
I soon realized the value of learning the coding elements for this type of project, and the field is quite interesting. It may be something im willing to chase as a career.........as a product developer, and someone who will often need to develop/prototype various electronics, which field of programming is most suited for me, in your opinion?? I chose Python because it seemed most relative, and lucrative, on its own.
Matthew Porter
3,892 PointsIm relatively new to programming myself, but it does seem like you are on the right track. Python and C++ may be the best for what you are trying to accomplish. Wish you the best.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi, Matthew! I changed your comment to an answer to mark the question as answered in the forums, allow for up voting of your answer, and potential selection of "Best Answer". Thanks for helping out in the Community!