Greetings Generator: Dodge the Bug!

Report a typo

Write a program that takes a user's name as input and prints a greeting message. Ensure your program correctly handles any common syntax errors found in beginner's code that could prevent it from running.

Sample Input 1:

Alice

Sample Output 1:

Hello, Alice!

Sample Input 2:

Bob

Sample Output 2:

Hello, Bob!
Write a program in Python 3
# Import necessary library for user input
import sys

def greet_user():
# Get the user's name from command line input
name = sys.argv[1]
# Print a greeting message
print(f"Hello, {name}!")

# Check if the script is the main entry point
if __name__ == '__main__':
greet_user()

Create a free account to access the full topic