Skip to main content
51 votes
Accepted

Password checker in Python

Concept Obligatory XKCD comic, before I begin: Enforcing password strength by requiring human-unfriendly characters is no longer considered good practice. Nevertheless, I'll review the code as you ...
200_success's user avatar
39 votes

Verifying a person's age

The biggest problem I see here is that you are printing a warning message to System.out and then using a default value for something which sounds like an Exception. ...
Simon Forsberg's user avatar
33 votes

Verifying IPv6 addresses

Python has a philosophy of "Batteries Included". Don't reinvent what's in the standard library! In particular, this code is much more easily written if we take advantage of ...
Toby Speight's user avatar
  • 77.3k
28 votes
Accepted

Verifying IPv6 addresses

You can change valid_characters to a string. 'ABCDEFabcdef:0123456789'. You can use ...
Peilonrayz's user avatar
  • 43.4k
24 votes
Accepted

Program to check if a date is valid or not

Good work! While there is certainly room for improvement, it is good that you stuck it out and discovered a solution on your own. ...
Gerrit0's user avatar
  • 3,456
22 votes
Accepted

Validating Yes/No answers in C++

You have a common bug that will send you into an infinite loop. :-) When reading data (especially user input data) you must validate the read worked correctly. If the read fails and sets one of the ...
Loki Astari's user avatar
  • 95.4k
20 votes

Validating Yes/No answers in C++

For a beginner, that's very good code. There is one thing that almost all C++ programmers get wrong, and that's calling ::tolower with a ...
Roland Illig's user avatar
  • 21.3k
19 votes

Checking if each char in a string is a decimal digit

In the cctype header, you have the std::isdigit(int) function. You can use this instead of your conditions that check if the ...
user2296177's user avatar
  • 3,543
17 votes
Accepted

Simple object validator

Instead of using regular expressions to manipulate the expression string I prefer to do expression manipulation. While this can be a little daunting at first it turns out to be fairly simple. It ...
Corey's user avatar
  • 805
16 votes

Checking if each char in a string is a decimal digit

The other reviews have hit most of the important points, so I'll just provide a single line alternative that uses the C++11 std::regex_match. That function looks ...
Edward's user avatar
  • 66.5k
12 votes
Accepted

Password Validation in Python

You shouldn't use bare excepts, this is as it can prevent things like KeyboardInterrupt. That's just bad. ...
Peilonrayz's user avatar
  • 43.4k
12 votes
Accepted

Checking some rules before a Telegram bot replies to a message

If you want to get rid of your nested code then you should make a function and use guard statements. If we simplify your code a bit, we can have: ...
Peilonrayz's user avatar
  • 43.4k
12 votes
Accepted

Pythonic way for validating and categorizing user input

Don't print promiscuously. You've broken your problem down into several small functions, which is a good general instinct. But you've undermined those functions by polluting them with side effects -- ...
FMc's user avatar
  • 12.8k
11 votes

Validating integer or string input

You are clearly violating the Single Responsibility Principle (SRP) because the method is doing two things. You should use two methods where each validates one type only. You will see also that for ...
Heslacher's user avatar
  • 50.4k
11 votes
Accepted

Enforcing string validity with the C# type system

Review I find this is a very nice idea that I have borrow from you and while doing this I'd change a couple things to make it more mature and even more flexible. ...
t3chb0t's user avatar
  • 44.3k
11 votes

Validate IP4 address

def validateIP(ip): I would expect a name starting is (a useful hint that it returns a Boolean rather than some more complex ...
Peter Taylor's user avatar
  • 24.1k
11 votes

Repetitive validation of Console inputs

As you suggested, you have a lot of redundant code. And rightfully so you want to adhere to the DRY principle. All these input methods have the same pattern internally.. ...
dfhwze's user avatar
  • 13.9k
11 votes

C Program which compares software version strings

Don't strtok + atoi. Use strtol, which (a) doesn't need a mutable input, (b) has much better ...
vnp's user avatar
  • 56.8k
10 votes
Accepted

Validating integer or string input

This is on top of what @Heslacher said. Flat is good Since the if branch of the first condition returns, you can eliminate the ...
janos's user avatar
  • 111k
10 votes

Checking if each char in a string is a decimal digit

Use the standard library Pass by const& if you only want to read from a variable (and not copy it) Mark functions that should not throw ...
Rakete1111's user avatar
  • 2,562
10 votes

Password checker in Python

You can make check_upper, check_lower, etc all use one function, and so you want to make a function such as ...
Peilonrayz's user avatar
  • 43.4k
10 votes

Verifying IPv6 addresses

Various comments in no specific order. The 2 last statements are identical, thus it is not relevant to check invalid_segment. You could write: ...
SylvainD's user avatar
  • 29.2k
10 votes

Validator for mathematical expression in infix form

Don’t write using namespace std;. You can, however, in a CPP file (not H file), or inside a function, put individual ...
JDługosz's user avatar
  • 11.4k
10 votes
Accepted

Python 3.6+ function to ask for a multiple-choice answer

The while True is fine, and is probably the best way to do it. However, the rest of the flow control is a bit clumsy. By rearranging a few statements, you can ...
200_success's user avatar
9 votes

Age verification module in Python

Current year If you don't want the current year to be hardcoded, you could use the method today() from datetime.date. ...
BusyAnt's user avatar
  • 639
9 votes
Accepted

Simple email validation script

Interface design The current design of the validator class is not very intuitive. Users of this class must call the check_for_symbol and ...
janos's user avatar
  • 111k
9 votes
Accepted

Validating a list of dictionaries of names and tags

There're some modules that might help you get rid of the structure you're complaining about like marshmallow or voluptous and since you didn't added the reinventing-the wheel tag I guess that's ...
Grajdeanu Alex's user avatar
9 votes

Program to check if a date is valid or not

For the most part, looks pretty good to me! Format You didn't use underscores to separate the words in a lot of variable names, which kinda bothered me. Snake_case is recommended by PEP8, so I ...
auden's user avatar
  • 431
9 votes
Accepted

Bash script to truncate subject line of incoming email

Be sure to read the relevant RFCs that govern e-mail headers! Specifically: RFC 2822, Section 1.2.2: Header names are case-insensitive. RFC 2822, Section 2.2.3: Header fields may be line-folded: 2....
200_success's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible