Conversation
wadirmalik1
left a comment
There was a problem hiding this comment.
- 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 | |||
|
|
|||
There was a problem hiding this comment.
Can you add comments and docstrings to your code.
|
|
||
| while True: | ||
| try: | ||
| names = input("Please enter the names separated by a space:").split() |
There was a problem hiding this comment.
I really like the use of the split() method here - good work!
|
|
||
| except: | ||
| pass | ||
| else: |
There was a problem hiding this comment.
What's the purpose of the else here?
| break | ||
|
|
||
|
|
||
| RNG() |
There was a problem hiding this comment.
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(): |
There was a problem hiding this comment.
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.
No description provided.