Skip to content

Ahmad random name generator#10

Open
ahmadsadik123 wants to merge 9 commits intoalexnaylor99:mainfrom
ahmadsadik123:main
Open

Ahmad random name generator#10
ahmadsadik123 wants to merge 9 commits intoalexnaylor99:mainfrom
ahmadsadik123:main

Conversation

@ahmadsadik123
Copy link

No description provided.

Copy link

@wadirmalik1 wadirmalik1 left a comment

Choose a reason for hiding this comment

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

  • I like the print Hello line to introduce the name generator.
  • the names variable you can split the input on one line.
  • Also no need to typecast the input to string as it will always be a string.
  • good use of global variable names
  • I'm confused about nameslist = list(set(names)). did you create a list of sets?
  • what if they enter a negative number?
  • what if the enter a number that's bigger than the size of the lists?
  • use doc strings to comment parts of your code to explain your thinking.

@@ -0,0 +1,38 @@
import random

Copy link
Owner

Choose a reason for hiding this comment

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

Can you add comments and docstrings to your code.


while True:
try:
names = input("Please enter the names separated by a space:").split()
Copy link
Owner

Choose a reason for hiding this comment

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

I really like the use of the split() method here - good work!


except:
pass
else:
Copy link
Owner

Choose a reason for hiding this comment

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

What's the purpose of the else here?

break


RNG()
Copy link
Owner

Choose a reason for hiding this comment

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

It's good practice to write the function call within the if name == "main": syntax. Look at the article for reference: https://realpython.com/if-name-main-python/#:~:text=If%20the%20__name__,Python%20skips%20the%20indented%20code.

break


def RNG():
Copy link
Owner

Choose a reason for hiding this comment

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

Hey Ahmad! Look at the defacto naming convention for Python functions. Also, there's no function understanding from the function name. You can give developers an idea of what the function is used for by giving it a descriptive name and adding docstrings.

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