Python Forum
Mad-lib script (beginner)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Mad-lib script (beginner)
#1
Hello everyone!

This is my first script I've wrote, it only took me like 20 minutes. It basically inputs your response and then it gives a madlib at the end. It's probably the most basic pathetic script you've ever read, but here it is.

adj = input("enter ADJ ")
adj2 = input("enter a ADJ ")
nationality = input("enter a nationality ")
person = input("enter a person ")
noun = input("enter a noun ")
noun2 = input("enter a noun ")
adj3 = input("enter a adj ")
adj4 = input("enter a adj ")
noun3 = input("enter a noun ")
plural_noun = input("enter a plural noun ")
number = input("enter a number ")
shapes = input("enter a shape ")
food1 = input("enter a food ")
food2 = input("enter a food ")
number2 = input("enter a number ")
print("Pizza was invented by a " + adj + nationality + "chef named " + person)
print("To make a pizza, you need to take a lump of " + noun + "and make a thin, round. " + adj2 + noun2)
print("Then you cover it with " + adj3 + "sauce " + adj4 + "cheese and fresh chopped " + plural_noun)
print("then you have to bake it in a very hot" + noun3 + "When it is done, cut it into " + number + shapes)
print("Some kids like " +food1 + "Pizza the best, but my favorite is the" + food2 + "pizza ")
print("IF I could, I would eat" + number + "times a day")

please delete this thread until I can figure out the bbcode.
Reply
#2
Congratulation on creating your first python program

You could try to change all your string concatenations to use the preferred Formatted string literals
Here is an example of one of your print lines
print("Pizza was invented by a " + adj + nationality + "chef named " + person)
as an f string
print(f"Pizza was invented by a {adj}{nationality}chef named {person}")
when you get the hang of them they are quite easy to use
Basically you just add an f in front of the string and your variables are directly inside of the string quotes and contained in between {}

(Jun-19-2020, 11:47 AM)eddiemyson Wrote: please delete this thread until I can figure out the bbcode.

There is no need to delete the thread, you'll get the hang of using code tags, in the meantime, I put them in for you.
Reply


Forum Jump:

User Panel Messages

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