i am getting an error "Code is unreachable Pylance" what that mean or am i doing any mistake in my code?
Olivia Zamora
def percent(marks): return (marks[0]+marks[1]+marks[2]+marks[3]/400)*100 marks1=[54,65,85,54] percent1=percent(marks1) marks2=[54,52,65,85] percent2 = percent(marks2) print(percent1,percent2) 2 Answers
The lines after return will not be executed anytime. So you can delete them and nothing will change. The message told you about it, because it is very unusual to have such code.
I think you wanted this:
def percent(marks): return (marks[0]+marks[1]+marks[2]+marks[3]/400)*100
marks1 = [54, 65, 85, 54]
percent1 = percent(marks1)
marks2 = [54, 52, 65, 85]
percent2 = percent(marks2)
print(percent1, percent2)Spaces in Python code matter. In your code all lines are the part of the function. In fixed code they are not.
i know why code is unreachable its because the interpreter thinks your program has closed. Something like exit()what is under exit() the code interpreter thinks cannot be executed, But it can be executed!