Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MadLib game
#1
I am in the pursuit of becoming an IT for cyber security and I have this online class that I'm pretty much learning on my own. I am stuck on the part which I need the output sample to include the whole story after having a user fill out the questions.

print = ("Enter the following words")
PNOUN1= input ("Give me a plural noun: ")
FNAME= input ("what is your name?: ")
NOUN1= input ("Give me a noun: ")
LNAME= input ("What is your last name?: ")
PNOUN2= input ("Give me a plural noun: ")
PLACE1= input ("Give me a place: ")
PNOUN3= input ("Give me a plural noun: ")
PLACE2= input ("Give me a place: ")
PNOUN4= input ("Give me a plural noun: ")
NOUN2= input ("Give me a noun: ")
ADJECTIVE1= input ("Give me an adjective: ")
ADJECTIVE2= input ("Give me an adjective: ")
VERB= input ("Give me a verb: ")
ADJECTIVE3= input ("Give me an adjective: ")

madlib ='''Hello there, sports {PNOUN1!}
This is {FNAME}, talking to you from the press {NOUN1}
in {LNAME} Stadium, where 57,000 cheering {PNOUN2}
Have gathered to watch (the) {PLACE1} {PNOUN3}
take on (the) {PLACE2} {PNOUN4}.
Even though the {NOUN2} is shining, its a/an {ADJECTIVE1}
cold day with the temperature in the {ADJECTIVE2} twenties.
We will be back for the opening {VERB} -off after a few words
from our {ADJECTIVE3} sponsor.'''
Larz60+ write Sep-16-2022, 09:09 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply
#2
print = ("Enter the following words")
This is overwriting the builtin print by assigning it to a string
remove the =
print("Enter the following words")

madlib ='''Hello there, sports {PNOUN1!}
...
An f is needed in front of the string to turn it into an fstring and the ! needs removing from the end of PNOUN1
madlib =f'''Hello there, sports {PNOUN1}
...
Then you can print out madlib with the variable being used inside the fstring
Reply
#3
I'm newbie and I don't understan it to much.
<link snipped>
Gribouillis write Jun-13-2023, 06:45 AM:
Off site promotion link removed. Please read What to NOT include in a post
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020