Q2. Valid Variable Name in Python

Which of the following is NOT a valid variable name in Python?

1.

var = 100

2.

number_1_ = "number1"

3.

[email protected] = "[email protected]"

4.

json11 = {}

Answer: 3

[email protected] = "[email protected]"

This is because variable names should not contain special characters like @. Here is the complete list of naming rules for Python variables.

Let’s look at other variables.

var – There is no var keyword in Python. So, it is valid.

number_1_ – It starts with an alphabet and doesn’t contain any special characters.

json11 – It is also valid because it contains alphabets and numbers.

Leave a Comment