Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

How can i restrict letters after a number in an input in Python

#Try this:

def input_string():
    x = input('str here: ')
    if 2 <= len(x) <= 6:
        number = False
        for i in range(len(x)):
            if i < 2:
                if not x[i].isupper():
                    return False
            else:
                if not number and x[i] in [str(a) for a in range(10)]:
                    number = True
                elif number:
                    if x[i] not in [str(a) for a in range(10)]:
                        return False
        return True
    return False
Comment

PREVIOUS NEXT
Code Example
Python :: how to add column to heroku postgres in my django app 
Python :: mechanize python #3 
Python :: get value of property of object with name python 
Python :: python custom class indexing 
Python :: create a list of sequential numbers in python 
Python :: how to create image folder in numpy aray 
Python :: python tabulate without index 
Python :: how to send image to template thats not in static flask 
Python :: get index of item in list 
Python :: python sepia filter 
Python :: python code to increase cpu utilization 
Python :: stores number in set using input in python 
Python :: python make dict 
Python :: Binary search tree deleting in python 
Python :: displaying data from this column where value is this python 
Python :: structural pattern matching python 
Python :: python divide all values in list 
Python :: wails install 
Python :: plt grid linestyles options 
Python :: activate venv environment 
Python :: python django adding category 
Python :: python bot ban script 
Python :: parser.add_argument array python 
Python :: matplotlib yaxis off 
Python :: how to comment python 
Python :: input a number and print even numbers up to that number 
Python :: label with list comprehension python 
Python :: python open file check error 
Python :: django serializer get image list 
Python :: python black 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =