Skip to content

Breakout Room 16 - Implementing Mad Libs Generator#17

Open
anselrognlie wants to merge 1 commit intomainfrom
Breakout-Room-16
Open

Breakout Room 16 - Implementing Mad Libs Generator#17
anselrognlie wants to merge 1 commit intomainfrom
Breakout-Room-16

Conversation

@anselrognlie
Copy link

No description provided.

@@ -1 +1,23 @@
#Mad Libs Generator Project
//Loop back to this point once code finishes
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using "#" instead of "/" for writing comments. "/" are used in JavaScript, Python uses "#"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Loop back to this point once code finishes
# Loop back to this point once code finishes

//Loop back to this point once code finishes
loop = 1
while (loop < 9):
// All the questions that the program asks the user
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// All the questions that the program asks the user
# All the questions that the program asks the user

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Displays the story based on the users input
# Displays the story based on the users input

print ("You may think that is this the",third_noun,",")
print ("Well it is.")
print ("------------------------------------------")
// Loop back to "loop = 1"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Loop back to "loop = 1"
# Loop back to "loop = 1"

#Mad Libs Generator Project
//Loop back to this point once code finishes
loop = 1
while (loop < 9):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A while loop works, however, when we have a fixed number of iterations it is better to use a for loop. In this case, a loop variable is not needed
for _ in range(10)

(https://www.geeksforgeeks.org/difference-between-for-loop-and-while-loop-in-python/)

noun = input("Choose a noun: ")
plural_noun = input("Choose a plural noun: ")
second_noun = input("Choose a noun: ")
place = input("Name a place: ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency, consider change "Name" for "Choose" as it is implemented on the other input messages.

// 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,",")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix variable name to "second_noun" instead of "seond_noun", otherwise, it is going to cause a NameError

Comment on lines +13 to +20
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.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For readability, consider using f-strings or string interpolation
print (f"Be kind to your {plural_noun} in {place}")

Copy link
Collaborator

@linakl19 linakl19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation works, and the requirements are met.
Here are a few general suggestions for improvement:

  • Replace // with # for writing comments in Python.
  • Instead of using a while loop, consider using a for loop with range(). You can refer to the single-line comments in the code for an example.
  • For better readability in print statements, use f-strings instead of comma-separated values.
  • To make the code more reusable, consider wrapping it in a function, such as create_story() (This is not necessary but is something good to consider)

Nice work so far. Looking forward to seeing how you refine it! Let me know if you have any questions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants