Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
      You have completed Practice Input and Output in Python!
      
    
You have completed Practice Input and Output in Python!
Preview
    
      
  Here's how I did it! How'd you do?
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
                      So how did you do?
                      0:00
                    
                    
                      I hope it was a good experience for
you and
                      0:01
                    
                    
                      that you didn't bang your head
on the keyboard too hard.
                      0:03
                    
                    
                      All right, so the first to do here,
we need to get some input from the user.
                      0:05
                    
                    
                      So I'm gonna go ahead and
I'm gonna use the input function, right?
                      0:10
                    
                    
                      So we're gonna say input, and
let's say please enter a verb.
                      0:16
                    
                    
                      And I'm gonna give a little breathing
space in this string here and
                      0:23
                    
                    
                      I'm gonna close my call.
                      0:26
                    
                    
                      And I wanna store that, right?
                      0:27
                    
                    
                      So I wanna store that in a variable,
in a name that I could remember later,
                      0:29
                    
                    
                      which what better to use than what's
actually in this blank here, right?
                      0:33
                    
                    
                      So I'm gonna use a verb,
so verb equals that.
                      0:37
                    
                    
                      So then whenever they enter here,
and this would get returned,
                      0:39
                    
                    
                      it would be stored in that verb variable.
                      0:43
                    
                    
                      Awesome, and
then I do the same for the others.
                      0:45
                    
                    
                      I'm just gonna go ahead and
copy and paste that.
                      0:49
                    
                    
                      You can type that out.
                      0:52
                    
                    
                      Here we go.
                      0:56
                    
                    
                      So please enter a noun,
please enter an adjective.
                      0:57
                    
                    
                      Again, with the space, so there's
a little bit of breathing room there, so
                      1:00
                    
                    
                      it's not right on top of it.
                      1:03
                    
                    
                      Awesome, awesome, so
that gets all of our prompts stored so
                      1:05
                    
                    
                      that we can use them in the next
TODO here, this output the template.
                      1:09
                    
                    
                      So the thing to remember here,
                      1:14
                    
                    
                      the trick is that the print
function takes multiple arguments.
                      1:16
                    
                    
                      And each argument that you give it,
gets joined together with a space.
                      1:20
                    
                    
                      So really, all we need to do is
call the print function, and
                      1:24
                    
                    
                      we wanna pass the first half,
up until this blank, to it.
                      1:29
                    
                    
                      So let's do that, so I'm gonna come up
here, and I'm gonna use the keyboard.
                      1:32
                    
                    
                      And see how it's highlighting that?
                      1:35
                    
                    
                      I'm gonna highlight it, and I'm going
to copy that, I'm gonna paste it there.
                      1:37
                    
                    
                      So that was Ctrl+C and
Ctrl+V, or Cmd+C and Cmd+V.
                      1:43
                    
                    
                      So I pasted it there, so
we have the first part.
                      1:48
                    
                    
                      And then I need to pass another argument,
so
                      1:51
                    
                    
                      I need to separate my
arguments with a comma.
                      1:54
                    
                    
                      And then I'm gonna do a space and
I'm gonna put in my variable name.
                      1:57
                    
                    
                      And again,
we want this blank to be this verb,
                      2:01
                    
                    
                      which the variable name was verb there,
right?
                      2:04
                    
                    
                      So we're gonna push whatever value
is stored in verb here, like so.
                      2:07
                    
                    
                      And then there's more to the sentence,
so we have more to finish up again.
                      2:11
                    
                    
                      So I'm gonna do another comma for
another argument here.
                      2:14
                    
                    
                      And I'll grab this last part here,
this better part here.
                      2:17
                    
                    
                      I'm not putting a space in here
cuz it's automatically happening
                      2:22
                    
                    
                      around the variable.
                      2:27
                    
                    
                      That's what the print statement does for
us.
                      2:29
                    
                    
                      And then from there,
the rest kind of just follows suit.
                      2:34
                    
                    
                      So we will say print, and
                      2:37
                    
                    
                      I can grab this, boom, and end that.
                      2:41
                    
                    
                      And put out my noun variable and
then get the last half here.
                      2:46
                    
                    
                      And you know what,
                      2:50
                    
                    
                      actually that little jump there, this
actually makes it kinda even more clear.
                      2:51
                    
                    
                      Make sure that you close
that quote off there.
                      2:56
                    
                    
                      We can just grab this line,
and we'll say print,
                      2:59
                    
                    
                      and I was gonna paste all of it in there.
                      3:04
                    
                    
                      And then we can just
put in the string here,
                      3:07
                    
                    
                      comma, get rid of that, blanks there.
                      3:11
                    
                    
                      Look at that,
looks exactly the same, cool.
                      3:13
                    
                    
                      And there we go.
                      3:20
                    
                    
                      What do you say?
                      3:21
                    
                    
                      Think we should run it?
                      3:22
                    
                    
                      Let's give it a go.
                      3:23
                    
                    
                      So let's see, please enter a verb.
                      3:28
                    
                    
                      How about learn, brain for our noun, and
                      3:30
                    
                    
                      how about beautiful,
it's a nice adjective.
                      3:34
                    
                    
                      I enjoy practice,
I find that it helps me to learn better.
                      3:40
                    
                    
                      Without practice,
my brain would probably not even work.
                      3:42
                    
                    
                      My code is getting more
beautiful every single day.
                      3:44
                    
                    
                      Pretty cool, isn't it?
                      3:47
                    
                    
                      You should be proud of this, you should
show this to your family and friends.
                      3:49
                    
                    
                      Switch the template out, make it say
whatever you want, have fun with it.
                      3:52
                    
                    
                      Practice is really important and
                      3:56
                    
                    
                      making sure that the information
that you're learning is sticking.
                      3:57
                    
                    
                      And I'm glad that you gave this a go.
                      4:00
                    
                    
                      Now, if you like this practice and
you'd like to see more of it,
                      4:02
                    
                    
                      please make sure to leave us some feedback
of what you'd like to see more of.
                      4:04
                    
                    
                      We rely heavily on your thoughts and
your ideas, so
                      4:08
                    
                    
                      please make sure that your voice is heard.
                      4:11
                    
                    
                      I hope you had fun, and
thanks for hanging out.
                      4:13
                    
                    
                      See you real soon.
                      4:16
                    
              
        You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up