-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Breakout Room 13: Update main.py #7
base: main
Are you sure you want to change the base?
Conversation
// Displays the story based on the users input | ||
print ("------------------------------------------") | ||
print ("Be kind to your",noun,"- footed", plural_noun) | ||
print ("For a duck may be somebody's", seond_noun,",") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to have a typo for the variable. Did you mean second_noun?
loop = 1 | ||
while (loop < 9): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't result in 10 stories for the user. Consider revising the loop variable and/or the ending range.
noun = input("Choose a noun: ") | ||
plural_noun = input("Choose a plural noun: ") | ||
second_noun = input("Choose a noun: ") | ||
place = input("Name a place: ") | ||
adjective = input("Choose an adjective (Describing word): ") | ||
third_noun = input("Choose a noun: ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding these to a data structure such as a dictionary might be useful for printing or organizing the story.
print ("------------------------------------------") | ||
print ("Be kind to your",noun,"- footed", plural_noun) | ||
print ("For a duck may be somebody's", seond_noun,",") | ||
print ("Be kind to your",plural_noun,"in",place) | ||
print ("Where the weather is always",adjective,".") | ||
print () | ||
print ("You may think that is this the",third_noun,",") | ||
print ("Well it is.") | ||
print ("------------------------------------------") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A helper function might be useful here for printing the story. It would keep the main code cleaner.
Also, an f-string and a single print statement could be helpful for readability.
print ("Well it is.") | ||
print ("------------------------------------------") | ||
// Loop back to "loop = 1" | ||
loop = loop + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A shorter way for this same code would be
loop += 1
loop = 1 | ||
while (loop < 9): | ||
// All the questions that the program asks the user | ||
noun = input("Choose a noun: ") | ||
plural_noun = input("Choose a plural noun: ") | ||
second_noun = input("Choose a noun: ") | ||
place = input("Name a place: ") | ||
adjective = input("Choose an adjective (Describing word): ") | ||
third_noun = input("Choose a noun: ") | ||
// Displays the story based on the users input | ||
print ("------------------------------------------") | ||
print ("Be kind to your",noun,"- footed", plural_noun) | ||
print ("For a duck may be somebody's", seond_noun,",") | ||
print ("Be kind to your",plural_noun,"in",place) | ||
print ("Where the weather is always",adjective,".") | ||
print () | ||
print ("You may think that is this the",third_noun,",") | ||
print ("Well it is.") | ||
print ("------------------------------------------") | ||
// Loop back to "loop = 1" | ||
loop = loop + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider putting all of this into a function that could be called for each story
@@ -1 +1,23 @@ | |||
#Mad Libs Generator Project | |||
//Loop back to this point once code finishes | |||
loop = 1 | |||
while (loop < 9): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A for loop might be useful here since we already know how many times it runs
No description provided.