0
0
Pythonprogramming~15 mins

String validation checks in Python - Mini Project: Build & Apply

Choose your learning style9 modes available
String validation checks
๐Ÿ“– Scenario: You are building a simple program to check different properties of a user's input text. This helps in many real-life cases like validating passwords, usernames, or form inputs.
๐ŸŽฏ Goal: Build a program that checks if a given string contains only letters, only digits, or is alphanumeric, and then prints the results.
๐Ÿ“‹ What You'll Learn
Create a variable with a specific string value
Create a variable to store a check result
Use string methods to check if the string is alphabetic, numeric, or alphanumeric
Print the results clearly
๐Ÿ’ก Why This Matters
๐ŸŒ Real World
String validation is used in forms, passwords, and user input to ensure data is correct and safe.
๐Ÿ’ผ Career
Many programming jobs require validating user input to prevent errors and security issues.
Progress0 / 4 steps
1
Create the input string
Create a variable called user_input and set it to the string "Hello123".
Python
Need a hint?

Use the equals sign = to assign the string to the variable.

2
Create variables for validation results
Create three variables called is_alpha, is_digit, and is_alnum. Set each one to False initially.
Python
Need a hint?

Each variable should be set to the boolean value False.

3
Check string properties using string methods
Set is_alpha to user_input.isalpha(), is_digit to user_input.isdigit(), and is_alnum to user_input.isalnum().
Python
Need a hint?

Use the string methods isalpha(), isdigit(), and isalnum() on user_input.

4
Print the validation results
Print the values of is_alpha, is_digit, and is_alnum each on a new line with labels exactly as shown: "Is alphabetic: ", "Is digit: ", and "Is alphanumeric: ".
Python
Need a hint?

Use three print() statements with the exact labels and variables.