Bird
0
0

Find the error in this variable name:

medium📝 Debug Q14 of 15
Python - Variables and Dynamic Typing
Find the error in this variable name:
user-name = 'Alice'
AVariable names cannot contain hyphens
BVariable names cannot start with a letter
CVariable names cannot contain underscores
DVariable names cannot be lowercase
Step-by-Step Solution
Solution:
  1. Step 1: Identify invalid characters in variable names

    Hyphens are not allowed in Python variable names because they are interpreted as minus signs.
  2. Step 2: Confirm other options are incorrect

    Variable names can start with letters, contain underscores, and be lowercase.
  3. Final Answer:

    Variable names cannot contain hyphens -> Option A
  4. Quick Check:

    Hyphens not allowed in names [OK]
Quick Trick: No hyphens in variable names; use underscores instead [OK]
Common Mistakes:
MISTAKES
  • Using hyphens instead of underscores
  • Thinking variable names can't start with letters
  • Confusing underscores with invalid characters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes