CBSE Class 11 Computer Science
Question 95 of 161
Flow of Control — Question 4
Back to all questions 4
Question Question 4
What is the error in following code? Correct the code:
weather = 'raining'
if weather = 'sunny' :
print ("wear sunblock")
elif weather = "snow":
print ("going skiing")
else :
print (weather) Answer
In this code, assignment operator (=) is used in place of equality operator (==) for comparison. The corrected code is below:
weather = 'raining'
if weather == 'sunny' :
print ("wear sunblock")
elif weather == "snow":
print ("going skiing")
else :
print (weather)