Daniel Smiley
Daniel Smiley

Reputation: 29

Why is this code incorrect?

I don't know what is wrong with this code. I am getting a syntax error, but I don't know why. Here is the code in Python:

1st_miles = 102

Need your help.

Upvotes: 1

Views: 105

Answers (3)

Muhammad Abdullah
Muhammad Abdullah

Reputation: 301

In this case, you are assigning 1st_miles the value of 102. This is syntactically wrong. In Python the variable (whom to which we assign values) should:

  1. Not start with a number.
  2. It can start with the alphabet and only underscore(_).

So in order to declare variables, you should start its name with the alphabet, not a digit. Example: first_miles = 102.

Hope this might helps.

Upvotes: 0

msalihbindak
msalihbindak

Reputation: 622

Your variables cannot start with a number.

Just try to use the following:

first_miles = 102

Upvotes: 1

Mureinik
Mureinik

Reputation: 311143

Identifiers in Python can't start with a digit. They must start with a letter or an underscore. E.g.:

first_miles = 102

Upvotes: 2

Related Questions