CBSE Class 12 Computer Science Question 85 of 105

Python Revision Tour II — Question 12

Back to all questions
12
Question

Question 5(e)

Find the errors. State reasons.

for Name in [Amar, Shveta, Parag]
    IF Name[0] = 'S':
        print(Name)
Answer

The errors in this code are:

  1. In the list [Amar, Shveta, Parag], each element should be enclosed in quotes because they are strings.
  2. The equality comparison operator is '==' instead of = for checking equality.
  3. if statement should be lowercase.