Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Which of these are valid variable names? Give a reason for each one that is not: my_age, 2fast, total-cost, _score, class.
No digit first, no space or hyphen, and not a keyword.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, compare your working with the solution.
my_age: valid.2fast: not valid. It starts with a digit.total-cost: not valid. A hyphen is not allowed. Use total_cost._score: valid. A name may start with an underscore.class: not valid. It is a keyword that Python already uses.Answer: my_age and _score.
Log in to join the discussion.
Loading…