Postcode Check
Write a function that receives the user's postcode as a parameter and checks whether the postcode is correct.
Postcode should be 15 digits
Postcode only contains numbers
Write a function that receives the user's postcode as a parameter and checks whether the postcode is correct.
Postcode should be 15 digits
Postcode only contains numbers
let msg = 'error' | |
alert(msg) |
This answer is only visible to premium members
let msg = 'error' | |
alert(msg) |
This answer is only visible to premium members
let msg = 'error' | |
alert(msg) |
This answer is only visible to premium members
def code_posti(name): | |
if len(name) == 3: | |
if name.isdigit(): | |
print('code posti cahihe') | |
else: | |
print("code posti 15 ragam nemibashade") | |
else: | |
print("code posti baiad 15 ragame bashda") | |
i = input('i: ') | |
code_posti(i) |
def postalcode(code): | |
return True if (len(code) == 15 and code.isnumeric() == True) else False | |
print(postalcode(code=input("Enter postal code: "))) |
def validate_postal_code(postal_code): | |
# Check that the codec is 15 digits and includes numbers only | |
if len(postal_code) == 15 and postal_code.isdigit(): | |
return True | |
else: | |
return False | |
def main(): | |
user_postal_code = input("لطفاً کدپستی خود را وارد کنید: ") | |
if validate_postal_code(user_postal_code): | |
print("کدپستی صحیح است.") | |
else: | |
print("کدپستی نادرست است. لطفاً اطمینان حاصل کنید که کدپستی 15 رقم و فقط شامل اعداد باشد.") | |
if __name__ == "__main__": | |
main() |
code = input('enter your code : ') | |
if len(code)== 15 and code == int: | |
print('ok') | |
else: | |
print('not ok') |
Code is not correct instead of CODE == int. You must use code.isdigit
def checkZipCode(zipCode): | |
if len(zipCode)==15: | |
for i in zipCode: | |
try: | |
toInt=int(i) | |
except: | |
return False | |
else: | |
return False | |
return True |
def post(n): | |
if len(n) == 15: | |
return True | |
else: | |
return False | |
print(post(n=(input("enter your number:")))) |
def x(a): | |
try: | |
int(a) | |
return len(a) == 15 | |
except: | |
return False | |
print(x(input("Enter Number :"))) |
Submitting answers is currently unavailable.
Write a program that receives a number of input and from that number to zero countdown and prints in the output
Write a program that prints an integers in the output. Get the desired interval from the input.
Build a table with HTML to show the following information: Name, Score, Hassan Hassani 17.25 Afforded Mohammadi Mohammed Hassani 13 Accept Mohammad Rezaei 9 Receives 19 Mardi Milad Mohammadi 12 ...
Write a program that receives a one -digit number from the input and finds the coefficient of smaller than 100 of those numbers and prints in the output
Write a program that receives a number and only by moving its figures, the smallest numbers can be found (with the same number of digits)
برای استفاده از این بخش باید وارد حساب کاربریت بشی
ورود/ثبت نام If you don’t understand the exercise or can’t solve it for any reason, that’s completely
normal—don’t worry 😊
Try checking out easier exercises and reviewing different answers
submitted by others. Gradually, you can move on to more challenging exercises. Also, your answer
might be correct even if it’s different from others.