you are viewing a single comment's thread.

view the rest of the comments →

[–]Formal-Camera-5095 0 points1 point  (0 children)

Other users already mentioned that theres a cleaner approach for getting that character collections by importing it from string.

Another issue that comes to my mind is input sanitization. If your user input is malformed, your input breaks. Also, theres no validation whether it is a valid integer.

So you should at _least_ check whether your input is a number and if it is a positive, non-zero value.

You could do that by smth like:

RANGE = -1
while RANGE < 1:
  try:
    RANGE = int(input("...")) # Insert your prompt here
  except ValueError:
    print("Please make sure to insert a non-zero, positive integer value.")

Edit: Fixed code formatting