Rewrite the following co,de in Python after removing all syntax errors(s). Underline each correction done in the co,de.
for Name in [Amar, Shveta, Parag]
if Name [0] = ‘s’:
Print (Name)
Answers
Answered by
9
Given code:
Corrected code:
Explanation:
Correction 1 & 2:
- Any text value must be enclosed in quotes to be represented as strings. In the given code, the names Amar, Shveta and Parag were not enclosed in quotes. The code would result in an error as Amar, Shveta and Parag are assumed to be variables instead of values.
- The syntax of a statement includes a colon at the end to indicate the next code block.
Correction 3:
- The equal to (=) and double-equal to (==) symbols are both different in Python. A single equal to symbol (=) represents an assignment, i.e., a value being assigned to a variable. A double-equal to symbol (==) represents a test for equality, i.e., the interpreter will check if the LHS and the RHS are equivalent.
Correction 4:
- The syntax of a statement is 'print' in smaller case. Since Python is a case-sensitive language, 'P' and 'p' are not the same.
Equestriadash:
Thanks for the Brainliest! ^_^"
Similar questions