
PYTHON — Collect User Input in Python
Privacy is not something that we’re merely entitled to, it’s an absolute prerequisite. — Marlon Brando

## Collecting User Input in Python
In Python, collecting user input can be done using the input() function. This allows users to provide data to the program during its execution. Here's an example of how to collect user input for a text-based game:
action = input("Do you want to (A)ttack, (H)eal, or (R)un away? ").upper()
if action == 'A':
print("You chose to attack")
elif action == 'H':
print("You chose to heal")
elif action == 'R':
print("You chose to run away")
else:
print("Invalid input")In this example, the input() function prompts the user to enter their action. The .upper() method is used to convert the input to uppercase, allowing the user to input either lowercase or uppercase characters.
When the user inputs a choice, it is compared using if-elif-else statements to determine the action to be taken within the game.
By using the input() function, you can create interactive programs that take user input and provide dynamic responses based on that input.
This simple example demonstrates the basic concept of collecting user input in Python and using it to make decisions within a program.
Remember, when using input(), you may need to validate and sanitize the user input based on the specific requirements of your program to prevent errors and ensure data integrity.






