I need to use firstnoun in the sentence "The [firstnoun] went to the lake.", where firstnoun is user inputted.
This is sort of what I have so far:
firstnoun = input("Enter your first noun here: ")
I need it to print:
The [firstnoun] went to the lake.
How do I do this? I tried doing
print("The" (print(firstnoun)) "went to the lake.")
and variations thereof, but none of that is working. I hope the question is clear enough.
Note: I'm a few weeks into a beginner python course so we're just learning the basics. Do I have to use def main()
here?
Looking at the python docs, you can find multiple ways.
or even using
format
with keywordsUse string concatenation to build the output you wish:
For more advanced formatting, use
format()
:You need to interpolate the value.
Here's a general example to show the concept which you can then apply to your homework:
x = "foo"
print("The word is {0}".format(x))
Also, no, a
main
function is not necessary.