Skip to content

Henry Opara - Python Project#22

Open
HenryXanderTalent wants to merge 10 commits intoalexnaylor99:mainfrom
HenryXanderTalent:main
Open

Henry Opara - Python Project#22
HenryXanderTalent wants to merge 10 commits intoalexnaylor99:mainfrom
HenryXanderTalent:main

Conversation

@HenryXanderTalent
Copy link

Please use option 2

Copy link

@ctorrington ctorrington left a comment

Choose a reason for hiding this comment

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

Reviews left! Really enjoyed the solution. :)

Comment on lines +158 to +168
#Retrieve initial input
'''The code below will add the initial name to the list'''
name_input = input("Enter a name to add to your shortlist or press enter to continue: ")

if name_input != '':

validateName(name_input)

else:

validateEntKey(name_input)

Choose a reason for hiding this comment

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

Nice to see the programme starting at the bottom of the file, I would recommend starting execution from inside a more standard structure such as below though. Here specifically, it would require setting the correct module name.

if '__name__' == '__main__': main()

Choose a reason for hiding this comment

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

I'm not sure about the newlines after every statement. It does make the code harder to read, especially with the multiple nested conditional statements, sometimes it is not possible to see where a statement has been nested.

Choose a reason for hiding this comment

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

The PEP8 standard for function names is snake_case.

#return output

#Add names to the list
def enterName():

Choose a reason for hiding this comment

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

This is the same logic as the code at the bottom of the file, there is no need to repeat the code.
This function could be called as entry into the programme.


print('Names entered must contain letters only')

name_input = None

Choose a reason for hiding this comment

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

You're not using the global variable for the name_input variable & so setting it to None here will only change it in the function scope, there is no need to do this since the function does not use the name_input variable again.

#Validate the number entered
def validateNum(num_input):
'''This function will validate the number entered is a number otherwise request a new entry'''
if num_input.isdigit() is not True:

Choose a reason for hiding this comment

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

isdigit() will return True if there are digits & False otherwise, there is no need to check if it is not True.
You could say, if not num_input.isdigit():.


addNum()

if num_input.isnumeric() is not True:

Choose a reason for hiding this comment

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

I'm not sure what the difference is between isdigit() & isnumeric() & if both are necessary.

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.

2 participants