I am writing a program that accepts user input.
#note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input`
age = int(input("Please enter your age: "))
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
The program works as expected as long as the the user enters meaningful data.
Please enter your age: 23
You are able to vote in the United States!
But it fails if the user enters invalid data:
Please enter your age: dickety six
Traceback (most recent call last):
File "canyouvote.py", line 1, in <module>
age = int(input("Please enter your age: "))
ValueError: invalid literal for int() with base 10: 'dickety six'
Instead of crashing, I would like the program to ask for the input again. Like this:
Please enter your age: dickety six
Sorry, I didn't understand that.
Please enter your age: 26
You are able to vote in the United States!
How do I ask for valid input instead of crashing or accepting invalid values (e.g. -1
)?
0
The simplest way to accomplish this is to put the input
method in a while loop. Use continue
when you get bad input, and break
out of the loop when you’re satisfied.
When Your Input Might Raise an Exception
Use try
and except
to detect when the user enters data that can’t be parsed.
while True:
try:
# Note: Python 2.x users should use raw_input, the equivalent of 3.x's input
age = int(input("Please enter your age: "))
except ValueError:
print("Sorry, I didn't understand that.")
#better try again... Return to the start of the loop
continue
else:
#age was successfully parsed!
#we're ready to exit the loop.
break
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
Implementing Your Own Validation Rules
If you want to reject values that Python can successfully parse, you can add your own validation logic.
while True:
data = input("Please enter a loud message (must be all caps): ")
if not data.isupper():
print("Sorry, your response was not loud enough.")
continue
else:
#we're happy with the value given.
#we're ready to exit the loop.
break
while True:
data = input("Pick an answer from A to D:")
if data.lower() not in ('a', 'b', 'c', 'd'):
print("Not an appropriate choice.")
else:
break
Combining Exception Handling and Custom Validation
Both of the above techniques can be combined into one loop.
while True:
try:
age = int(input("Please enter your age: "))
except ValueError:
print("Sorry, I didn't understand that.")
continue
if age < 0:
print("Sorry, your response must not be negative.")
continue
else:
#age was successfully parsed, and we're happy with its value.
#we're ready to exit the loop.
break
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
Encapsulating it All in a Function
If you need to ask your user for a lot of different values, it might be useful to put this code in a function, so you don’t have to retype it every time.
def get_non_negative_int(prompt):
while True:
try:
value = int(input(prompt))
except ValueError:
print("Sorry, I didn't understand that.")
continue
if value < 0:
print("Sorry, your response must not be negative.")
continue
else:
break
return value
age = get_non_negative_int("Please enter your age: ")
kids = get_non_negative_int("Please enter the number of children you have: ")
salary = get_non_negative_int("Please enter your yearly earnings, in dollars: ")
Putting It All Together
You can extend this idea to make a very generic input function:
def sanitised_input(prompt, type_=None, min_=None, max_=None, range_=None):
if min_ is not None and max_ is not None and max_ < min_:
raise ValueError("min_ must be less than or equal to max_.")
while True:
ui = input(prompt)
if type_ is not None:
try:
ui = type_(ui)
except ValueError:
print("Input type must be {0}.".format(type_.__name__))
continue
if max_ is not None and ui > max_:
print("Input must be less than or equal to {0}.".format(max_))
elif min_ is not None and ui < min_:
print("Input must be greater than or equal to {0}.".format(min_))
elif range_ is not None and ui not in range_:
if isinstance(range_, range):
template = "Input must be between {0.start} and {0.stop}."
print(template.format(range_))
else:
template = "Input must be {0}."
if len(range_) == 1:
print(template.format(*range_))
else:
expected = " or ".join((
", ".join(str(x) for x in range_[:-1]),
str(range_[-1])
))
print(template.format(expected))
else:
return ui
With usage such as:
age = sanitised_input("Enter your age: ", int, 1, 101)
answer = sanitised_input("Enter your answer: ", str.lower, range_=('a', 'b', 'c', 'd'))
Common Pitfalls, and Why you Should Avoid Them
The Redundant Use of Redundant input
Statements
This method works but is generally considered poor style:
data = input("Please enter a loud message (must be all caps): ")
while not data.isupper():
print("Sorry, your response was not loud enough.")
data = input("Please enter a loud message (must be all caps): ")
It might look attractive initially because it’s shorter than the while True
method, but it violates the Don’t Repeat Yourself principle of software development. This increases the likelihood of bugs in your system. What if you want to backport to 2.7 by changing input
to raw_input
, but accidentally change only the first input
above? It’s a SyntaxError
just waiting to happen.
Recursion Will Blow Your Stack
If you’ve just learned about recursion, you might be tempted to use it in get_non_negative_int
so you can dispose of the while loop.
def get_non_negative_int(prompt):
try:
value = int(input(prompt))
except ValueError:
print("Sorry, I didn't understand that.")
return get_non_negative_int(prompt)
if value < 0:
print("Sorry, your response must not be negative.")
return get_non_negative_int(prompt)
else:
return value
This appears to work fine most of the time, but if the user enters invalid data enough times, the script will terminate with a RuntimeError: maximum recursion depth exceeded
. You may think “no fool would make 1000 mistakes in a row”, but you’re underestimating the ingenuity of fools!
9
Why would you do a while True
and then break out of this loop while you can also just put your requirements in the while statement since all you want is to stop once you have the age?
age = None
while age is None:
input_value = input("Please enter your age: ")
try:
# try and convert the string input to a number
age = int(input_value)
except ValueError:
# tell the user off
print("{input} is not a number, please enter a number only".format(input=input_value))
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
This would result in the following:
Please enter your age: *potato*
potato is not a number, please enter a number only
Please enter your age: *5*
You are not able to vote in the United States.
this will work since age will never have a value that will not make sense and the code follows the logic of your “business process”
1
Functional approach or “look mum no loops!“:
from itertools import chain, repeat
prompts = chain(["Enter a number: "], repeat("Not a number! Try again: "))
replies = map(input, prompts)
valid_response = next(filter(str.isdigit, replies))
print(valid_response)
Enter a number: a
Not a number! Try again: b
Not a number! Try again: 1
1
or if you want to have a “bad input” message separated from an input prompt as in other answers:
prompt_msg = "Enter a number: "
bad_input_msg = "Sorry, I didn't understand that."
prompts = chain([prompt_msg], repeat('n'.join([bad_input_msg, prompt_msg])))
replies = map(input, prompts)
valid_response = next(filter(str.isdigit, replies))
print(valid_response)
Enter a number: a
Sorry, I didn't understand that.
Enter a number: b
Sorry, I didn't understand that.
Enter a number: 1
1
How does it work?
-
prompts = chain(["Enter a number: "], repeat("Not a number! Try again: "))
This combination of
itertools.chain
anditertools.repeat
will create an iterator
which will yield strings"Enter a number: "
once, and"Not a number! Try again: "
an infinite number of times:for prompt in prompts: print(prompt)
Enter a number: Not a number! Try again: Not a number! Try again: Not a number! Try again: # ... and so on
replies = map(input, prompts)
– heremap
will apply all theprompts
strings from the previous step to theinput
function. E.g.:for reply in replies: print(reply)
Enter a number: a a Not a number! Try again: 1 1 Not a number! Try again: it doesn't care now it doesn't care now # and so on...
- We use
filter
andstr.isdigit
to filter out those strings that contain only digits:only_digits = filter(str.isdigit, replies) for reply in only_digits: print(reply)
Enter a number: a Not a number! Try again: 1 1 Not a number! Try again: 2 2 Not a number! Try again: b Not a number! Try again: # and so on...
And to get only the first digits-only string we use
next
.
Other validation rules:
-
String methods: Of course you can use other string methods like
str.isalpha
to get only alphabetic strings, orstr.isupper
to get only uppercase. See docs for the full list. -
Membership testing:
There are several different ways to perform it. One of them is by using__contains__
method:from itertools import chain, repeat fruits = {'apple', 'orange', 'peach'} prompts = chain(["Enter a fruit: "], repeat("I don't know this one! Try again: ")) replies = map(input, prompts) valid_response = next(filter(fruits.__contains__, replies)) print(valid_response)
Enter a fruit: 1 I don't know this one! Try again: foo I don't know this one! Try again: apple apple
-
Numbers comparison:
There are useful comparison methods which we can use here. For example, for__lt__
(<
):from itertools import chain, repeat prompts = chain(["Enter a positive number:"], repeat("I need a positive number! Try again:")) replies = map(input, prompts) numeric_strings = filter(str.isnumeric, replies) numbers = map(float, numeric_strings) is_positive = (0.).__lt__ valid_response = next(filter(is_positive, numbers)) print(valid_response)
Enter a positive number: a I need a positive number! Try again: -5 I need a positive number! Try again: 0 I need a positive number! Try again: 5 5.0
Or, if you don’t like using dunder methods (dunder = double-underscore), you can always define your own function, or use the ones from the
operator
module. -
Path existance:
Here one can usepathlib
library and itsPath.exists
method:from itertools import chain, repeat from pathlib import Path prompts = chain(["Enter a path: "], repeat("This path doesn't exist! Try again: ")) replies = map(input, prompts) paths = map(Path, replies) valid_response = next(filter(Path.exists, paths)) print(valid_response)
Enter a path: a b c This path doesn't exist! Try again: 1 This path doesn't exist! Try again: existing_file.txt existing_file.txt
Limiting number of tries:
If you don’t want to torture a user by asking him something an infinite number of times, you can specify a limit in a call of itertools.repeat
. This can be combined with providing a default value to the next
function:
from itertools import chain, repeat
prompts = chain(["Enter a number:"], repeat("Not a number! Try again:", 2))
replies = map(input, prompts)
valid_response = next(filter(str.isdigit, replies), None)
print("You've failed miserably!" if valid_response is None else 'Well done!')
Enter a number: a
Not a number! Try again: b
Not a number! Try again: c
You've failed miserably!
Preprocessing input data:
Sometimes we don’t want to reject an input if the user accidentally supplied it IN CAPS or with a space in the beginning or an end of the string. To take these simple mistakes into account we can preprocess the input data by applying str.lower
and str.strip
methods. For example, for the case of membership testing the code will look like this:
from itertools import chain, repeat
fruits = {'apple', 'orange', 'peach'}
prompts = chain(["Enter a fruit: "], repeat("I don't know this one! Try again: "))
replies = map(input, prompts)
lowercased_replies = map(str.lower, replies)
stripped_replies = map(str.strip, lowercased_replies)
valid_response = next(filter(fruits.__contains__, stripped_replies))
print(valid_response)
Enter a fruit: duck
I don't know this one! Try again: Orange
orange
In the case when you have many functions to use for preprocessing, it might be easier to use a function performing a function composition. For example, using the one from here:
from itertools import chain, repeat
from lz.functional import compose
fruits = {'apple', 'orange', 'peach'}
prompts = chain(["Enter a fruit: "], repeat("I don't know this one! Try again: "))
replies = map(input, prompts)
process = compose(str.strip, str.lower) # you can add more functions here
processed_replies = map(process, replies)
valid_response = next(filter(fruits.__contains__, processed_replies))
print(valid_response)
Enter a fruit: potato
I don't know this one! Try again: PEACH
peach
Combining validation rules:
For a simple case, for example, when the program asks for age between 1 and 120, one can just add another filter
:
from itertools import chain, repeat
prompt_msg = "Enter your age (1-120): "
bad_input_msg = "Wrong input."
prompts = chain([prompt_msg], repeat('n'.join([bad_input_msg, prompt_msg])))
replies = map(input, prompts)
numeric_replies = filter(str.isdigit, replies)
ages = map(int, numeric_replies)
positive_ages = filter((0).__lt__, ages)
not_too_big_ages = filter((120).__ge__, positive_ages)
valid_response = next(not_too_big_ages)
print(valid_response)
But in the case when there are many rules, it’s better to implement a function performing a logical conjunction. In the following example I will use a ready one from here:
from functools import partial
from itertools import chain, repeat
from lz.logical import conjoin
def is_one_letter(string: str) -> bool:
return len(string) == 1
rules = [str.isalpha, str.isupper, is_one_letter, 'C'.__le__, 'P'.__ge__]
prompt_msg = "Enter a letter (C-P): "
bad_input_msg = "Wrong input."
prompts = chain([prompt_msg], repeat('n'.join([bad_input_msg, prompt_msg])))
replies = map(input, prompts)
valid_response = next(filter(conjoin(*rules), replies))
print(valid_response)
Enter a letter (C-P): 5
Wrong input.
Enter a letter (C-P): f
Wrong input.
Enter a letter (C-P): CDE
Wrong input.
Enter a letter (C-P): Q
Wrong input.
Enter a letter (C-P): N
N
Unfortunately, if someone needs a custom message for each failed case, then, I’m afraid, there is no pretty functional way. Or, at least, I couldn’t find one.
Though the accepted answer is amazing. I would also like to share a quick hack for this problem. (This takes care of the negative age problem as well.)
f=lambda age: (age.isdigit() and ((int(age)>=18 and "Can vote" ) or "Cannot vote")) or
f(input("invalid input. Try againnPlease enter your age: "))
print(f(input("Please enter your age: ")))
P.S. This code is for python 3.x.
6
Using Click:
Click is a library for command-line interfaces and it provides functionality for asking a valid response from a user.
Simple example:
import click
number = click.prompt('Please enter a number', type=float)
print(number)
Please enter a number:
a
Error: a is not a valid floating point value
Please enter a number:
10
10.0
Note how it converted the string value to a float automatically.
Checking if a value is within a range:
There are different custom types provided. To get a number in a specific range we can use IntRange
:
age = click.prompt("What's your age?", type=click.IntRange(1, 120))
print(age)
What's your age?:
a
Error: a is not a valid integer
What's your age?:
0
Error: 0 is not in the valid range of 1 to 120.
What's your age?:
5
5
We can also specify just one of the limits, min
or max
:
age = click.prompt("What's your age?", type=click.IntRange(min=14))
print(age)
What's your age?:
0
Error: 0 is smaller than the minimum valid value 14.
What's your age?:
18
18
Membership testing:
Using click.Choice
type. By default this check is case-sensitive.
choices = {'apple', 'orange', 'peach'}
choice = click.prompt('Provide a fruit', type=click.Choice(choices, case_sensitive=False))
print(choice)
Provide a fruit (apple, peach, orange):
banana
Error: invalid choice: banana. (choose from apple, peach, orange)
Provide a fruit (apple, peach, orange):
OrAnGe
orange
Working with paths and files:
Using a click.Path
type we can check for existing paths and also resolve them:
path = click.prompt('Provide path', type=click.Path(exists=True, resolve_path=True))
print(path)
Provide path:
nonexistent
Error: Path "nonexistent" does not exist.
Provide path:
existing_folder
'/path/to/existing_folder
Reading and writing files can be done by click.File
:
file = click.prompt('In which file to write data?', type=click.File('w'))
with file.open():
file.write('Hello!')
# More info about `lazy=True` at:
# https://click.palletsprojects.com/en/7.x/arguments/#file-opening-safety
file = click.prompt('Which file you wanna read?', type=click.File(lazy=True))
with file.open():
print(file.read())
In which file to write data?:
# <-- provided an empty string, which is an illegal name for a file
In which file to write data?:
some_file.txt
Which file you wanna read?:
nonexistent.txt
Error: Could not open file: nonexistent.txt: No such file or directory
Which file you wanna read?:
some_file.txt
Hello!
Other examples:
Password confirmation:
password = click.prompt('Enter password', hide_input=True, confirmation_prompt=True)
print(password)
Enter password:
······
Repeat for confirmation:
·
Error: the two entered values do not match
Enter password:
······
Repeat for confirmation:
······
qwerty
Default values:
In this case, simply pressing Enter (or whatever key you use) without entering a value, will give you a default one:
number = click.prompt('Please enter a number', type=int, default=42)
print(number)
Please enter a number [42]:
a
Error: a is not a valid integer
Please enter a number [42]:
42
1
I am a big fan of Unix philosophy “Do one thing and do it well”. Capturing user input and validating it are two separate steps:
- prompting the user for input with
get_input
until the input is ok - validating using a
validator
function that can be passed toget_input
It can be kept as simple as (Python 3.8+, with the walrus operator):
def get_input(
prompt="Enter a value: ",
validator=lambda x: True,
error_message="Invalid input. Please try again.",
):
while not validator(value := input(prompt)):
print(error_message)
return value
def is_positive_int(value):
try:
return int(value) >= 0
except ValueError:
return False
if __name__ == "__main__":
val = get_input("Give a positive number: ", is_positive_int)
print(f"OK, thanks for {val}")
Sample run:
Give a positive number: -5
Invalid input. Please try again.
Give a positive number: asdf
Invalid input. Please try again.
Give a positive number:
Invalid input. Please try again.
Give a positive number: 42
OK, thanks for 42
In Python < 3.8 you could use get_input
like this:
def get_input(
prompt="Enter a value: ",
validator=lambda x: True,
error_message="Invalid input. Please try again.",
):
while True:
value = input(prompt)
if validator(value):
return value
print(error_message)
You might also handle KeyboardInterrupt
and print a friendly exit message before terminating the application. A counter can be used to limit the allowed retries if desired.
0
So, I was messing around with something similar to this recently, and I came up with the following solution, which uses a way of getting input that rejects junk, before it’s even checked in any logical way.
read_single_keypress()
courtesy /a/6599441/4532996
def read_single_keypress() -> str:
"""Waits for a single keypress on stdin.
-- from :: /a/6599441/4532996
"""
import termios, fcntl, sys, os
fd = sys.stdin.fileno()
# save old state
flags_save = fcntl.fcntl(fd, fcntl.F_GETFL)
attrs_save = termios.tcgetattr(fd)
# make raw - the way to do this comes from the termios(3) man page.
attrs = list(attrs_save) # copy the stored version to update
# iflag
attrs[0] &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK
| termios.ISTRIP | termios.INLCR | termios. IGNCR
| termios.ICRNL | termios.IXON )
# oflag
attrs[1] &= ~termios.OPOST
# cflag
attrs[2] &= ~(termios.CSIZE | termios. PARENB)
attrs[2] |= termios.CS8
# lflag
attrs[3] &= ~(termios.ECHONL | termios.ECHO | termios.ICANON
| termios.ISIG | termios.IEXTEN)
termios.tcsetattr(fd, termios.TCSANOW, attrs)
# turn off non-blocking
fcntl.fcntl(fd, fcntl.F_SETFL, flags_save & ~os.O_NONBLOCK)
# read a single keystroke
try:
ret = sys.stdin.read(1) # returns a single character
except KeyboardInterrupt:
ret = 0
finally:
# restore old state
termios.tcsetattr(fd, termios.TCSAFLUSH, attrs_save)
fcntl.fcntl(fd, fcntl.F_SETFL, flags_save)
return ret
def until_not_multi(chars) -> str:
"""read stdin until !(chars)"""
import sys
chars = list(chars)
y = ""
sys.stdout.flush()
while True:
i = read_single_keypress()
_ = sys.stdout.write(i)
sys.stdout.flush()
if i not in chars:
break
y += i
return y
def _can_you_vote() -> str:
"""a practical example:
test if a user can vote based purely on keypresses"""
print("can you vote? age : ", end="")
x = int("0" + until_not_multi("0123456789"))
if not x:
print("nsorry, age can only consist of digits.")
return
print("your age is", x, "nYou can vote!" if x >= 18 else "Sorry! you can't vote")
_can_you_vote()
You can find the complete module here.
Example:
$ ./input_constrain.py
can you vote? age : a
sorry, age can only consist of digits.
$ ./input_constrain.py
can you vote? age : 23<RETURN>
your age is 23
You can vote!
$ _
Note that the nature of this implementation is it closes stdin as soon as something that isn’t a digit is read. I didn’t hit enter after a
, but I needed to after the numbers.
You could merge this with the thismany()
function in the same module to only allow, say, three digits.
2
Use try-except to handle the error and repeat it again:
while True:
try:
age = int(input("Please enter your age: "))
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
except Exception as e:
print("please enter number")
1
Building upon Daniel Q’s and Patrick Artner’s excellent suggestions,
here is an even more generalized solution.
# Assuming Python3
import sys
class ValidationError(ValueError): # thanks Patrick Artner
pass
def validate_input(prompt, cast=str, cond=(lambda x: True), onerror=None):
if onerror==None: onerror = {}
while True:
try:
data = cast(input(prompt))
if not cond(data): raise ValidationError
return data
except tuple(onerror.keys()) as e: # thanks Daniel Q
print(onerror[type(e)], file=sys.stderr)
I opted for explicit if
and raise
statements instead of an assert
,
because assertion checking may be turned off,
whereas validation should always be on to provide robustness.
This may be used to get different kinds of input,
with different validation conditions.
For example:
# No validation, equivalent to simple input:
anystr = validate_input("Enter any string: ")
# Get a string containing only letters:
letters = validate_input("Enter letters: ",
cond=str.isalpha,
onerror={ValidationError: "Only letters, please!"})
# Get a float in [0, 100]:
percentage = validate_input("Percentage? ",
cast=float, cond=lambda x: 0.0<=x<=100.0,
onerror={ValidationError: "Must be between 0 and 100!",
ValueError: "Not a number!"})
Or, to answer the original question:
age = validate_input("Please enter your age: ",
cast=int, cond=lambda a:0<=a<150,
onerror={ValidationError: "Enter a plausible age, please!",
ValueError: "Enter an integer, please!"})
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
def validate_age(age):
if age >=0 :
return True
return False
while True:
try:
age = int(raw_input("Please enter your age:"))
if validate_age(age): break
except ValueError:
print "Error: Invalid age."
Good question! You can try the following code for this. =)
This code uses ast.literal_eval() to find the data type of the input (age
). Then it follows the following algorithm:
Ask user to input her/his
age
.1.1. If
age
isfloat
orint
data type:
Check if
age>=18
. Ifage>=18
, print appropriate output and exit.Check if
0<age<18
. If0<age<18
, print appropriate output and exit.If
age<=0
, ask the user to input a valid number for age again, (i.e. go back to step 1.)1.2. If
age
is notfloat
orint
data type, then ask user to input her/his age again (i.e. go back to step 1.)
Here is the code.
from ast import literal_eval
''' This function is used to identify the data type of input data.'''
def input_type(input_data):
try:
return type(literal_eval(input_data))
except (ValueError, SyntaxError):
return str
flag = True
while(flag):
age = raw_input("Please enter your age: ")
if input_type(age)==float or input_type(age)==int:
if eval(age)>=18:
print("You are able to vote in the United States!")
flag = False
elif eval(age)>0 and eval(age)<18:
print("You are not able to vote in the United States.")
flag = False
else: print("Please enter a valid number as your age.")
else: print("Sorry, I didn't understand that.")
Try this one:-
def takeInput(required):
print 'ooo or OOO to exit'
ans = raw_input('Enter: ')
if not ans:
print "You entered nothing...!"
return takeInput(required)
## FOR Exit ##
elif ans in ['ooo', 'OOO']:
print "Closing instance."
exit()
else:
if ans.isdigit():
current = 'int'
elif set('[~!@#$%^&*()_+{}":/']+$').intersection(ans):
current = 'other'
elif isinstance(ans,basestring):
current = 'str'
else:
current = 'none'
if required == current :
return ans
else:
return takeInput(required)
## pass the value in which type you want [str/int/special character(as other )]
print "input: ", takeInput('str')
Use “while” statement till user enter a true value and if the input value is not a number or it’s a null value skip it and try to ask again and so on.
In example I tried to answer truly your question. If we suppose that our age is between 1 and 150 then input value accepted, else it’s a wrong value.
For terminating program, the user can use 0 key and enter it as a value.
Note: Read comments top of code.
# If your input value is only a number then use "Value.isdigit() == False".
# If you need an input that is a text, you should remove "Value.isdigit() == False".
def Input(Message):
Value = None
while Value == None or Value.isdigit() == False:
try:
Value = str(input(Message)).strip()
except Exception:
Value = None
return Value
# Example:
age = 0
# If we suppose that our age is between 1 and 150 then input value accepted,
# else it's a wrong value.
while age <=0 or age >150:
age = int(Input("Please enter your age: "))
# For terminating program, the user can use 0 key and enter it as an a value.
if age == 0:
print("Terminating ...")
exit(0)
if age >= 18 and age <=150:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
You can always apply simple if-else logic and add one more if
logic to your code along with a for
loop.
while True:
age = int(input("Please enter your age: "))
if (age >= 18) :
print("You are able to vote in the United States!")
if (age < 18) & (age > 0):
print("You are not able to vote in the United States.")
else:
print("Wrong characters, the input must be numeric")
continue
This will be an infinite loo and you would be asked to enter the age, indefinitely.
1
While a try
/except
block will work, a much faster and cleaner way to accomplish this task would be to use str.isdigit()
.
while True:
age = input("Please enter your age: ")
if age.isdigit():
age = int(age)
break
else:
print("Invalid number '{age}'. Try again.".format(age=age))
if age >= 18:
print("You are able to vote in the United States!")
else:
print("You are not able to vote in the United States.")
0
You can write more general logic to allow user to enter only specific number of times, as the same use-case arises in many real-world applications.
def getValidInt(iMaxAttemps = None):
iCount = 0
while True:
# exit when maximum attempt limit has expired
if iCount != None and iCount > iMaxAttemps:
return 0 # return as default value
i = raw_input("Enter no")
try:
i = int(i)
except ValueError as e:
print "Enter valid int value"
else:
break
return i
age = getValidInt()
# do whatever you want to do.
1
You can make the input statement a while True loop so it repeatedly asks for the users input and then break that loop if the user enters the response you would like. And you can use try and except blocks to handle invalid responses.
while True:
var = True
try:
age = int(input("Please enter your age: "))
except ValueError:
print("Invalid input.")
var = False
if var == True:
if age >= 18:
print("You are able to vote in the United States.")
break
else:
print("You are not able to vote in the United States.")
The var variable is just so that if the user enters a string instead of a integer the program wont return “You are not able to vote in the United States.”
One more solution for using input validation using a customized ValidationError
and a (optional) range validation for integer inputs:
class ValidationError(ValueError):
"""Special validation error - its message is supposed to be printed"""
pass
def RangeValidator(text,num,r):
"""Generic validator - raises 'text' as ValidationError if 'num' not in range 'r'."""
if num in r:
return num
raise ValidationError(text)
def ValidCol(c):
"""Specialized column validator providing text and range."""
return RangeValidator("Columns must be in the range of 0 to 3 (inclusive)",
c, range(4))
def ValidRow(r):
"""Specialized row validator providing text and range."""
return RangeValidator("Rows must be in the range of 5 to 15(exclusive)",
r, range(5,15))
Usage:
def GetInt(text, validator=None):
"""Aks user for integer input until a valid integer is given. If provided,
a 'validator' function takes the integer and either raises a
ValidationError to be printed or returns the valid number.
Non integers display a simple error message."""
print()
while True:
n = input(text)
try:
n = int(n)
return n if validator is None else validator(n)
except ValueError as ve:
# prints ValidationErrors directly - else generic message:
if isinstance(ve, ValidationError):
print(ve)
else:
print("Invalid input: ", n)
column = GetInt("Pleased enter column: ", ValidCol)
row = GetInt("Pleased enter row: ", ValidRow)
print( row, column)
Output:
Pleased enter column: 22
Columns must be in the range of 0 to 3 (inclusive)
Pleased enter column: -2
Columns must be in the range of 0 to 3 (inclusive)
Pleased enter column: 2
Pleased enter row: a
Invalid input: a
Pleased enter row: 72
Rows must be in the range of 5 to 15(exclusive)
Pleased enter row: 9
9, 2
Persistent user input using recursive function:
String
def askName():
return input("Write your name: ").strip() or askName()
name = askName()
Integer
def askAge():
try: return int(input("Enter your age: "))
except ValueError: return askAge()
age = askAge()
and finally, the question requirement:
def askAge():
try: return int(input("Enter your age: "))
except ValueError: return askAge()
age = askAge()
responseAge = [
"You are able to vote in the United States!",
"You are not able to vote in the United States.",
][int(age < 18)]
print(responseAge)
You can try to convert it to a integer, but ask the user to repeat if it doesn’t work.
while True:
age = input('Please enter your age: ')
try:
age_int = int(age)
if age_int >= 18:
print('You can vote in the United States!')
else:
print('You cannot vote in the United States.')
break
except:
print('Please enter a meaningful answer.')
The while loop runs as long as the user has not inputted a meaningful answer, but breaks if it makes sense.
Use isdigit()
to check if a string represents a valid integer.
You could use a recursive function.
def ask():
answer = input("Please enter amount to convert: ")
if not answer.isdigit():
print("Invalid")
return ask()
return int(answer)
Gdp = ask()
Or a while loop
while True:
answer = input("Please enter amount to convert: ")
if not answer.isdigit():
print("Invalid")
continue
Gbp = int(answer)
3
Below code may help.
age=(lambda i,f: f(i,f))(input("Please enter your age: "),lambda i,f: i if i.isdigit() else f(input("Please enter your age: "),f))
print("You are able to vote in the united states" if int(age)>=18 else "You are not able to vote in the united states",end='')
If you want to have maximum tries, say 3, use below code
age=(lambda i,n,f: f(i,n,f))(input("Please enter your age: "),1,lambda i,n,f: i if i.isdigit() else (None if n==3 else f(input("Please enter your age: "),n+1,f)))
print("You are able to vote in the united states" if age and int(age)>=18 else "You are not able to vote in the united states",end='')
Note: This uses recursion.
2
Sinh nhật phong cách metal
Tổ chức sinh nhật tại nhà jazz
Dịch vụ sinh nhật xuất sắc hơn
Tiệc sinh nhật cho nhà ngôn ngữ học
Thuê nhóm nhảy metal sinh nhật
Sinh nhật chủ đề sang trọng
Tổ chức sinh nhật tại nhà pop
Dịch vụ sinh nhật hoàn mỹ hơn
Tiệc sinh nhật cho nhà văn học
Trang trí sinh nhật bằng đồ garnet
Sinh nhật phong cách punk rock
Tổ chức sinh nhật tại nhà reggae
Dịch vụ sinh nhật tuyệt vời hơn nữa
Tiệc sinh nhật cho nhà khảo cổ học
Thuê nhóm nhảy punk sinh nhật
Sinh nhật chủ đề ấm cúng
Tổ chức sinh nhật tại nhà blues
Dịch vụ sinh nhật đỉnh cao hơn nữa
Tiệc sinh nhật cho nhà địa lý học
Trang trí sinh nhật bằng đồ aquamarine
Sinh nhật phong cách alternative
Tổ chức sinh nhật tại nhà country
Dịch vụ sinh nhật chất lượng hơn
Tiệc sinh nhật cho nhà thiên văn học
Thuê nhóm nhảy alternative sinh nhật
Sinh nhật chủ đề lãng mạn
Tổ chức sinh nhật tại nhà folk
Dịch vụ sinh nhật sáng chói hơn nữa
Tiệc sinh nhật cho nhà triết học
Trang trí sinh nhật bằng đồ citrine
Sinh nhật phong cách ska
Tổ chức sinh nhật tại nhà techno
Dịch vụ sinh nhật rực rỡ hơn nữa
Tiệc sinh nhật cho nhà kinh tế học
Thuê nhóm nhảy ska sinh nhật
Sinh nhật chủ đề truyền thống
Tổ chức sinh nhật tại nhà electronic
Dịch vụ sinh nhật lung linh hơn nữa
Tiệc sinh nhật cho nhà sử học
Trang trí sinh nhật bằng đồ peridot
Sinh nhật phong cách R&B
Tổ chức sinh nhật tại nhà disco
Dịch vụ sinh nhật đẹp hơn nữa
Tiệc sinh nhật cho nhà nhân học
Thuê nhóm nhảy R&B sinh nhật
Sinh nhật chủ đề phá cách
Tổ chức sinh nhật tại nhà funk
Dịch vụ sinh nhật hoàn toàn hơn nữa
Tiệc sinh nhật cho nhà luật học
Trang trí sinh nhật bằng đồ moonstone
Sinh nhật phong cách gospel
Tổ chức sinh nhật tại nhà soul
Dịch vụ sinh nhật độc đáo hơn nữa
Tiệc sinh nhật cho nhà chính trị học
Thuê nhóm nhảy gospel sinh nhật
Sinh nhật chủ đề nghệ thuật
Tổ chức sinh nhật tại nhà rap
Dịch vụ sinh nhật xuất sắc hơn nữa
Tiệc sinh nhật cho nhà tài chính học
Trang trí sinh nhật bằng đồ onyx
Sinh nhật phong cách hip hop dance
Tổ chức sinh nhật tại nhà indie
Dịch vụ sinh nhật hoàn mỹ hơn nữa
Tiệc sinh nhật cho nhà quản trị học
Thuê nhóm nhảy hip hop sinh nhật
Sinh nhật chủ đề đồng quê
Tổ chức sinh nhật tại nhà acoustic
Dịch vụ sinh nhật tuyệt vời hơn hết
Tiệc sinh nhật cho nhà kỹ thuật học
Trang trí sinh nhật bằng đồ jade
Sinh nhật phong cách breakdance
Tổ chức sinh nhật tại nhà chill
Dịch vụ sinh nhật đỉnh cao hơn hết
Tiệc sinh nhật cho nhà công nghệ học
Thuê nhóm nhảy breakdance sinh nhật
Sinh nhật chủ đề hoàng gia
Tổ chức sinh nhật tại nhà lounge
Dịch vụ sinh nhật chất lượng hơn hết
Tiệc sinh nhật cho nhà nghiên cứu học
Trang trí sinh nhật bằng đồ lapis lazuli
Sinh nhật phong cách street dance
Tổ chức sinh nhật tại nhà classical
Dịch vụ sinh nhật sáng chói hơn hết
Tiệc sinh nhật cho nhà phân tích học
Thuê nhóm nhảy street sinh nhật
Sinh nhật chủ đề huyền bí
Tổ chức sinh nhật tại nhà grunge
Dịch vụ sinh nhật rực rỡ hơn hết
Tiệc sinh nhật cho nhà xã hội học
Trang trí sinh nhật bằng đồ malachite
Sinh nhật phong cách contemporary
Tổ chức sinh nhật tại nhà metal
Dịch vụ sinh nhật lung linh hơn hết
Tiệc sinh nhật cho nhà giáo dục học
Thuê nhóm nhảy contemporary sinh nhật
Sinh nhật chủ đề nhiệt đới
Tổ chức sinh nhật tại nhà punk rock
Dịch vụ sinh nhật đẹp hơn hết
Tiệc sinh nhật cho nhà tâm lý học
Trang trí sinh nhật bằng đồ amber
Sinh nhật phong cách ballet
Tổ chức sinh nhật tại nhà alternative
Dịch vụ sinh nhật hoàn toàn hơn hết
Tiệc sinh nhật cho nhà ngôn ngữ học
Thuê nhóm nhảy ballet sinh nhật
Sinh nhật chủ đề mùa đông
Tổ chức sinh nhật tại nhà ska
Dịch vụ sinh nhật độc đáo hơn hết
Trợ lý AI thông minh nhất cho bạn
Khám phá công nghệ AI tại đây
Trải nghiệm trợ lý ảo tuyệt vời
Công cụ AI hỗ trợ mọi công việc
Tăng năng suất với AI thông minh
AI thay đổi cách bạn làm việc
Trợ lý ảo đáng tin cậy nhất
Khám phá tương lai với AI
Công nghệ AI tiên tiến cho bạn
Hỗ trợ thông minh từ trợ lý AI
AI giúp bạn tiết kiệm thời gian
Trợ lý ảo tốt nhất hiện nay
Công nghệ AI đỉnh cao
Khám phá sức mạnh của AI
Trợ lý AI hỗ trợ 24/7
Công cụ AI cho mọi nhu cầu
AI thông minh, nhanh chóng
Trợ lý ảo dẫn đầu xu hướng
Công nghệ AI dành cho bạn
Hỗ trợ công việc với AI
Trợ lý AI tối ưu hóa công việc
Khám phá AI hiện đại
Công cụ AI đáng kinh ngạc
Trợ lý ảo thông minh vượt trội
AI giúp bạn thành công
Công nghệ AI đáng tin cậy
Trợ lý ảo cho tương lai
Khám phá công cụ AI mới
AI hỗ trợ mọi lúc mọi nơi
Trợ lý ảo thông minh hàng đầu
Công nghệ AI thay đổi cuộc sống
Hỗ trợ tối đa với AI
Trợ lý AI sáng tạo nhất
Công cụ AI mạnh mẽ
Khám phá trợ lý ảo AI
AI thông minh cho mọi người
Trợ lý ảo tối ưu nhất
Công nghệ AI vượt trội
Hỗ trợ công việc bằng AI
Trợ lý AI cho mọi ngành
Khám phá sức mạnh AI
Công cụ AI thông minh nhất
Trợ lý ảo dẫn dắt tương lai
AI hỗ trợ không giới hạn
Công nghệ AI sáng tạo
Trợ lý ảo hiệu quả nhất
Khám phá công nghệ AI đỉnh cao
AI giúp bạn tỏa sáng
Trợ lý ảo thông minh toàn diện
Công cụ AI thay đổi mọi thứ
Trợ lý AI giúp bạn làm việc nhanh hơn
Công nghệ AI hiện đại nhất hiện nay
Trải nghiệm AI thông minh vượt bậc
Công cụ AI hỗ trợ sáng tạo
Trợ lý ảo dành cho mọi nhà
AI tối ưu hóa công việc hàng ngày
Khám phá trợ lý AI tiên tiến
Công nghệ AI cho doanh nghiệp
Trợ lý ảo giúp bạn tiết kiệm sức lực
AI thông minh hỗ trợ cá nhân
Công cụ AI cho tương lai gần
Trợ lý ảo tối ưu mọi tác vụ
Khám phá công nghệ AI độc đáo
AI giúp bạn đạt hiệu quả cao
Trợ lý ảo thông minh và thân thiện
Công nghệ AI dành cho mọi ngành
Trợ lý AI hỗ trợ liên tục
Khám phá sức mạnh AI vượt trội
Công cụ AI giúp bạn nổi bật
Trợ lý ảo cho công việc hiện đại
AI thông minh dẫn đầu thời đại
Công nghệ AI hỗ trợ toàn diện
Trợ lý ảo giúp bạn sáng tạo hơn
Khám phá AI thông minh hàng đầu
Công cụ AI tối ưu cho bạn
Trợ lý AI thay đổi cách làm việc
Công nghệ AI mạnh mẽ và linh hoạt
Trợ lý ảo thông minh cho mọi người
AI hỗ trợ công việc hiệu quả
Khám phá công cụ AI sáng tạo
Trợ lý ảo giúp bạn thành công hơn
Công nghệ AI dẫn dắt tương lai
Trợ lý AI tối ưu cho doanh nghiệp
AI thông minh hỗ trợ mọi lúc
Công cụ AI dành cho sáng tạo
Trợ lý ảo giúp bạn tiết kiệm chi phí
Khám phá trợ lý AI độc quyền
Công nghệ AI thay đổi mọi ngành
Trợ lý AI thông minh cho cuộc sống
AI hỗ trợ công việc nhóm
Công cụ AI hiện đại và mạnh mẽ
Trợ lý ảo tối ưu hóa thời gian
Khám phá sức mạnh AI thông minh
Công nghệ AI cho mọi nhu cầu
Trợ lý AI giúp bạn đi trước thời đại
AI thông minh hỗ trợ cá nhân hóa
Công cụ AI tối ưu cho công việc
Trợ lý ảo dẫn đầu công nghệ
Khám phá AI vượt xa mong đợi
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh và hiệu quả
AI hỗ trợ bạn mọi lúc mọi nơi
Công cụ AI thay đổi cách sống
Trợ lý ảo tối ưu cho tương lai
Khám phá công nghệ AI tiên phong
Công nghệ AI giúp bạn tỏa sáng
Trợ lý AI hỗ trợ công việc sáng tạo
AI thông minh cho mọi lĩnh vực
Công cụ AI dẫn đầu xu hướng
Trợ lý ảo giúp bạn phát triển
Khám phá trợ lý AI mạnh mẽ
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh cho doanh nhân
AI tối ưu hóa mọi quy trình
Công cụ AI sáng tạo và thông minh
Trợ lý ảo giúp bạn quản lý thời gian
Khám phá sức mạnh của công nghệ AI
Công nghệ AI thay đổi cách nghĩ
Trợ lý AI hỗ trợ mọi dự án
AI thông minh cho cuộc sống hiện đại
Công cụ AI giúp bạn đi xa hơn
Trợ lý ảo tối ưu cho sáng tạo
Khám phá AI thông minh vượt trội
Công nghệ AI dành cho tương lai
Trợ lý AI giúp bạn thành công lớn
AI hỗ trợ công việc hiệu quả hơn
Công cụ AI thông minh và linh hoạt
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá công nghệ AI sáng tạo
Công nghệ AI tối ưu hóa cuộc sống
Trợ lý AI thông minh cho mọi ngành
AI giúp bạn quản lý công việc
Công cụ AI dành cho thành công
Trợ lý ảo hỗ trợ không giới hạn
Khám phá trợ lý AI thông minh nhất
Công nghệ AI thay đổi mọi thứ
Trợ lý AI tối ưu cho doanh nghiệp
AI thông minh hỗ trợ sáng tạo
Công cụ AI giúp bạn tiết kiệm thời gian
Trợ lý ảo dẫn dắt tương lai
Khám phá sức mạnh AI hiện đại
Công nghệ AI cho mọi người
Trợ lý AI thông minh và đáng tin cậy
AI hỗ trợ bạn vượt qua thử thách
Công cụ AI tối ưu hóa công việc
Trợ lý ảo giúp bạn phát triển nhanh
Khám phá công nghệ AI tiên tiến
Công nghệ AI sáng tạo cho bạn
Trợ lý AI hỗ trợ mọi nhu cầu
AI thông minh thay đổi cuộc chơi
Công cụ AI dẫn đầu mọi lĩnh vực
Trợ lý ảo tối ưu cho mọi tác vụ
Khám phá trợ lý AI vượt trội
Công nghệ AI giúp bạn thành công
Trợ lý AI thông minh cho tương lai
AI hỗ trợ công việc sáng tạo
Công cụ AI thông minh vượt bậc
Trợ lý ảo giúp bạn quản lý hiệu quả
Khám phá sức mạnh AI sáng tạo
Công nghệ AI tối ưu cho cuộc sống
Trợ lý AI thông minh và hiện đại
AI giúp bạn đi trước xu hướng
Công cụ AI hỗ trợ không ngừng
Trợ lý ảo dẫn đầu công nghệ AI
Khám phá công nghệ AI thông minh
Công nghệ AI thay đổi cách làm việc
Trợ lý AI tối ưu hóa sáng tạo
AI thông minh cho mọi công việc
Công cụ AI giúp bạn phát triển
Trợ lý ảo hỗ trợ mọi lúc
Khám phá trợ lý AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn tối ưu hóa thời gian
Công cụ AI mạnh mẽ cho bạn
Trợ lý ảo dẫn dắt mọi ngành
Khám phá sức mạnh AI thông minh
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI tối ưu cho sáng tạo
AI thông minh thay đổi tương lai
Công cụ AI giúp bạn thành công hơn
Trợ lý ảo hỗ trợ không giới hạn
Khám phá công nghệ AI hiện đại
Công nghệ AI sáng tạo cho mọi người
Trợ lý AI thông minh vượt mong đợi
AI giúp bạn quản lý công việc tốt hơn
Công cụ AI tối ưu cho doanh nghiệp
Trợ lý ảo dẫn đầu xu hướng công nghệ
Khám phá trợ lý AI sáng tạo
Công nghệ AI hỗ trợ mọi lĩnh vực
Trợ lý AI thông minh cho cuộc sống
AI tối ưu hóa công việc hàng ngày
Công cụ AI giúp bạn đi xa hơn
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá sức mạnh AI vượt trội
Công nghệ AI thay đổi cách sống
Trợ lý AI tối ưu cho tương lai
AI thông minh hỗ trợ sáng tạo
Công cụ AI dẫn đầu mọi xu hướng
Trợ lý ảo giúp bạn phát triển nhanh
Khám phá công nghệ AI tiên phong
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn tối ưu hóa hiệu suất
Công cụ AI mạnh mẽ và hiệu quả
Trợ lý ảo dẫn dắt tương lai
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ không giới hạn
Trợ lý AI tối ưu cho mọi ngành
AI thông minh thay đổi mọi thứ
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo hỗ trợ mọi lúc mọi nơi
Khám phá sức mạnh AI hiện đại
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh vượt trội
AI giúp bạn quản lý thời gian tốt hơn
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo dẫn đầu công nghệ
Khám phá công nghệ AI vượt bậc
Công nghệ AI hỗ trợ mọi công việc
Trợ lý AI thông minh cho mọi người
AI tối ưu hóa cuộc sống hàng ngày
Công cụ AI giúp bạn phát triển
Trợ lý ảo hỗ trợ không ngừng
Khám phá trợ lý AI tiên tiến
Công nghệ AI sáng tạo và mạnh mẽ
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho mọi nhu cầu
Trợ lý ảo dẫn dắt mọi xu hướng
Khám phá sức mạnh AI sáng tạo
Công nghệ AI thay đổi cách làm việc
Trợ lý AI thông minh và hiệu quả
AI hỗ trợ bạn vượt qua khó khăn
Công cụ AI giúp bạn tỏa sáng
Trợ lý ảo tối ưu cho công việc
Khám phá công nghệ AI thông minh
Công nghệ AI sáng tạo không giới hạn
Trợ lý AI thông minh cho tương lai
AI giúp bạn quản lý hiệu quả hơn
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo dẫn đầu mọi lĩnh vực
Khám phá trợ lý AI vượt trội
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh cho mọi ngành
AI tối ưu hóa công việc sáng tạo
Công cụ AI giúp bạn thành công
Trợ lý ảo hỗ trợ mọi lúc
Khám phá sức mạnh AI tiên phong
Công nghệ AI sáng tạo vượt bậc
Trợ lý AI thông minh và mạnh mẽ
AI giúp bạn tối ưu hóa thời gian
Công cụ AI dẫn đầu công nghệ
Trợ lý ảo tối ưu cho doanh nghiệp
Khám phá công nghệ AI hiện đại
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh cho cuộc sống
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn dắt tương lai
Khám phá trợ lý AI sáng tạo
Công nghệ AI thay đổi mọi ngành
Trợ lý AI thông minh vượt trội
AI giúp bạn quản lý công việc
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá sức mạnh AI thông minh
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và hiệu quả
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn đi trước xu hướng
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá công nghệ AI tiên tiến
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn tối ưu hóa công việc
Công cụ AI sáng tạo và mạnh mẽ
Trợ lý ảo tối ưu cho tương lai
Khám phá trợ lý AI vượt bậc
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh cho mọi người
AI hỗ trợ bạn thành công lớn
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá sức mạnh AI sáng tạo
Công nghệ AI tối ưu cho bạn
Trợ lý AI thông minh và đáng tin cậy
AI giúp bạn quản lý thời gian
Công cụ AI hỗ trợ không giới hạn
Trợ lý ảo tối ưu hóa sáng tạo
Khám phá công nghệ AI thông minh
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nhân
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn tỏa sáng
Trợ lý ảo dẫn đầu công nghệ
Khám phá trợ lý AI tiên phong
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh vượt mong đợi
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho công việc
Trợ lý ảo hỗ trợ không ngừng
Khám phá sức mạnh AI hiện đại
Công nghệ AI sáng tạo cho mọi ngành
Trợ lý AI thông minh và hiệu quả
AI tối ưu hóa cuộc sống hàng ngày
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn dắt tương lai
Khám phá công nghệ AI vượt trội
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh cho mọi người
AI giúp bạn quản lý công việc
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá trợ lý AI sáng tạo
Công nghệ AI thay đổi mọi thứ
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa công việc hiệu quả
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá sức mạnh AI thông minh
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn tối ưu hóa thời gian
Công cụ AI hỗ trợ không giới hạn
Trợ lý ảo tối ưu cho tương lai
Khám phá công nghệ AI tiên tiến
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh và mạnh mẽ
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá trợ lý AI vượt trội
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh cho mọi ngành
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ không ngừng
Khám phá sức mạnh AI hiện đại
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn đi trước xu hướng
Trợ lý ảo dẫn đầu công nghệ
Khám phá công nghệ AI thông minh
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn tối ưu hóa công việc
Công cụ AI sáng tạo và hiệu quả
Trợ lý ảo tối ưu cho mọi người
Khám phá trợ lý AI tiên phong
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh vượt trội
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá sức mạnh AI sáng tạo
Công nghệ AI hỗ trợ không giới hạn
Trợ lý AI thông minh cho mọi ngành
AI giúp bạn quản lý thời gian
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá công nghệ AI vượt bậc
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và hiệu quả
AI tối ưu hóa công việc hàng ngày
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh vượt mong đợi
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho doanh nghiệp
Trợ lý ảo hỗ trợ không ngừng
Khám phá sức mạnh AI hiện đại
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh cho mọi người
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá công nghệ AI tiên tiến
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh vượt trội
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ không giới hạn
Khám phá trợ lý AI sáng tạo
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh cho doanh nghiệp
AI tối ưu hóa công việc sáng tạo
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn đầu công nghệ
Khám phá sức mạnh AI vượt bậc
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và hiệu quả
AI giúp bạn đi trước xu hướng
Công cụ AI tối ưu cho mọi người
Trợ lý ảo hỗ trợ mọi lúc mọi nơi
Khám phá công nghệ AI thông minh
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá trợ lý AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn quản lý thời gian
Công cụ AI tối ưu hóa công việc
Trợ lý ảo hỗ trợ không giới hạn
Khám phá sức mạnh AI sáng tạo
Công nghệ AI thay đổi mọi ngành
Trợ lý AI thông minh và mạnh mẽ
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá công nghệ AI vượt trội
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh cho mọi người
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ mọi lúc
Khám phá trợ lý AI thông minh
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa công việc hiệu quả
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá sức mạnh AI tiên phong
Công nghệ AI hỗ trợ không giới hạn
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá công nghệ AI hiện đại
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và hiệu quả
AI tối ưu hóa cuộc sống hàng ngày
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn đầu công nghệ
Khám phá trợ lý AI vượt trội
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh vượt mong đợi
AI giúp bạn đi trước xu hướng
Công cụ AI tối ưu cho doanh nghiệp
Trợ lý ảo hỗ trợ không ngừng
Khám phá sức mạnh AI sáng tạo
Công nghệ AI thay đổi mọi thứ
Trợ lý AI thông minh cho mọi người
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá công nghệ AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh và mạnh mẽ
AI giúp bạn quản lý thời gian
Công cụ AI tối ưu hóa công việc
Trợ lý ảo hỗ trợ không giới hạn
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá sức mạnh AI vượt trội
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và hiệu quả
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá công nghệ AI hiện đại
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá trợ lý AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ không giới hạn
Khám phá sức mạnh AI thông minh
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh và mạnh mẽ
AI tối ưu hóa công việc hàng ngày
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn đầu công nghệ
Khám phá công nghệ AI vượt bậc
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh vượt trội
AI giúp bạn đi trước xu hướng
Công cụ AI tối ưu cho mọi người
Trợ lý ảo hỗ trợ mọi lúc mọi nơi
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá sức mạnh AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn quản lý thời gian
Công cụ AI tối ưu hóa công việc
Trợ lý ảo hỗ trợ không giới hạn
Khám phá công nghệ AI hiện đại
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá trợ lý AI thông minh
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh vượt trội
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá sức mạnh AI vượt bậc
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh và hiệu quả
AI tối ưu hóa công việc hàng ngày
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá công nghệ AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ không ngừng
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn đầu công nghệ
Khám phá sức mạnh AI sáng tạo
Công nghệ AI thay đổi mọi ngành
Trợ lý AI thông minh và mạnh mẽ
AI giúp bạn đi trước xu hướng
Công cụ AI tối ưu cho mọi người
Trợ lý ảo hỗ trợ mọi lúc mọi nơi
Khám phá công nghệ AI vượt trội
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá trợ lý AI tiên phong
Công nghệ AI hỗ trợ không giới hạn
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn quản lý thời gian
Công cụ AI tối ưu hóa công việc
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá sức mạnh AI thông minh
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và hiệu quả
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá công nghệ AI hiện đại
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh vượt trội
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ không ngừng
Khám phá trợ lý AI thông minh
Công nghệ AI sáng tạo vượt bậc
Trợ lý AI thông minh cho doanh nghiệp
AI tối ưu hóa công việc hàng ngày
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá sức mạnh AI tiên phong
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh vượt mong đợi
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ không giới hạn
Khám phá công nghệ AI vượt trội
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và mạnh mẽ
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn đầu công nghệ
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh vượt bậc
AI giúp bạn đi trước xu hướng
Công cụ AI tối ưu cho mọi người
Trợ lý ảo hỗ trợ mọi lúc mọi nơi
Khám phá sức mạnh AI sáng tạo
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh vượt trội
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá công nghệ AI tiên phong
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn quản lý thời gian
Công cụ AI tối ưu hóa công việc
Trợ lý ảo hỗ trợ không giới hạn
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá sức mạnh AI vượt trội
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh và hiệu quả
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá công nghệ AI hiện đại
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa công việc hàng ngày
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá trợ lý AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ không giới hạn
Khám phá sức mạnh AI thông minh
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh và mạnh mẽ
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn đầu công nghệ
Khám phá công nghệ AI vượt trội
Công nghệ AI sáng tạo cho bạn
Trợ lý AI thông minh vượt mong đợi
AI giúp bạn đi trước xu hướng
Công cụ AI tối ưu cho mọi người
Trợ lý ảo hỗ trợ mọi lúc mọi nơi
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ không ngừng
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá sức mạnh AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn quản lý thời gian
Công cụ AI tối ưu hóa công việc
Trợ lý ảo hỗ trợ không giới hạn
Khám phá công nghệ AI hiện đại
Công nghệ AI hỗ trợ mọi lúc
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa mọi quy trình
Công cụ AI giúp bạn phát triển
Trợ lý ảo dẫn đầu mọi xu hướng
Khám phá trợ lý AI thông minh
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh vượt trội
AI giúp bạn đi trước thời đại
Công cụ AI tối ưu cho sáng tạo
Trợ lý ảo hỗ trợ mọi nhu cầu
Khám phá sức mạnh AI vượt bậc
Công nghệ AI thay đổi cách sống
Trợ lý AI thông minh và hiệu quả
AI tối ưu hóa công việc hàng ngày
Công cụ AI giúp bạn thành công
Trợ lý ảo dẫn dắt mọi lĩnh vực
Khám phá công nghệ AI tiên phong
Công nghệ AI sáng tạo vượt trội
Trợ lý AI thông minh cho doanh nghiệp
AI giúp bạn quản lý hiệu quả
Công cụ AI tối ưu hóa sáng tạo
Trợ lý ảo hỗ trợ không giới hạn
Khám phá trợ lý AI thông minh
Công nghệ AI hỗ trợ toàn diện
Trợ lý AI thông minh vượt mong đợi
AI tối ưu hóa mọi công việc
Công cụ AI giúp bạn phát triển nhanh
Trợ lý ảo dẫn đầu công nghệ
Khám phá sức mạnh AI sáng tạo
Công nghệ AI thay đổi mọi ngành
Trợ lý AI thông minh và mạnh mẽ
AI giúp bạn đi trước xu hướng
Công cụ AI tối ưu cho mọi người
Trợ lý ảo hỗ trợ mọi lúc mọi nơi
Khám phá công nghệ AI vượt trội
Công nghệ AI sáng tạo không ngừng
Trợ lý AI thông minh vượt bậc
AI tối ưu hóa cuộc sống hiện đại
Công cụ AI giúp bạn thành công lớn
Trợ lý ảo dẫn dắt tương lai
Khám phá trợ lý AI tiên phong
Công nghệ AI hỗ trợ không giới hạn
Trợ lý AI thông minh cho doanh nhân
AI giúp bạn quản lý thời gian
Xổ số miền Nam Kết quả xổ số miền Nam XSMN hôm nay KQXS miền Nam XSMN trực tiếp KQXS hôm nay Xổ số kiến thiết miền Nam Dự đoán XSMN Xổ số miền Nam 24h XSMN chuẩn Kết quả xổ số nhanh Xổ số miền Nam hôm qua XSMN VIP Xổ số miền Nam 7 ngày Xổ số miền Nam chính xác XSMN 3 miền XSMN mới nhất Trực tiếp xổ số miền Nam Xổ số miền Nam hôm nay KQXS miền Nam chính xác Xổ số miền Nam hàng ngày Xổ số miền Nam nhanh nhất Dò vé số miền Nam Xổ số miền Nam chính thống Xổ số kiến thiết Kết quả xổ số miền Nam mới nhất XSMN cực nhanh Thống kê XSMN Dò xổ số miền Nam Xổ số online miền Nam KQXS hôm qua Xổ số nhanh nhất XSMN uy tín KQXS hôm nay nhanh nhất Dự đoán KQXS miền Nam Xổ số siêu tốc Xổ số VIP Xổ số miền Nam 30 ngày Lịch mở thưởng XSMN Xổ số hôm nay XSMN 2025 Dò vé số hôm nay Xổ số miền Nam miễn phí Trực tiếp KQXS miền Nam Dò xổ số nhanh Dự đoán XSMN chuẩn Xổ số 3 miền chính xác Thống kê xổ số miền Nam Dự đoán lô đề XSMN Kết quả XSMN online Kết quả xổ số 3 miền Dò xổ số VIP XSMN miễn phí Xổ số dễ trúng Xổ số miền Nam mỗi ngày Dự đoán XSMN hôm nay Thống kê kết quả XSMN Xổ số miền Nam hôm nay nhanh nhất Xổ số miền Nam mới nhất Xổ số miền Nam hôm qua Dự đoán xổ số miền Nam