Knowledge organisersString Manipulation
Check patterns in text.
String methods like .isalpha(), .isdigit(), and .isalnum() check whether a string contains only certain types of characters. They return True or False.
.isalpha() — True if all letters.isdigit() — True if all digits.isalnum() — True if letters or digits onlyFalse for all checkspostcode = input("Postcode: ")
if postcode.isalnum() and len(postcode) >= 5:
print("Valid format")
else:
print("Invalid postcode")