World's Best AI Learning Platform with profoundly Demanding Certification Programs
Designed by IITians, only for AI Learners.
Designed by IITians, only for AI Learners.
New to InsideAIML? Create an account
Employer? Create an account
Getting error
Code:
num = int(input(f"Enter the Marks received: ")) percent = num/100 if percent>0.60: for x in range(5): print("salute") print("\n") else: for x in range(5): print("punishment") print("\n")
Output:
Cell In [7], line 6 print("salute") ^ IndentationError: expected an indented block after 'for' statement on line 5
Hit tab before print salute, and print punishment
The error message is indicating that there is an indentation error on line 6, specifically that the print("salute")
statement should be indented one more level to be inside the for
loop on line 5.
The code should be:
num = int(input(f"Enter the Marks received: ")) percent = num/100 if percent>0.60: for x in range(5): print("salute") print("\n") else: for x in range(5): print("punishment") print("\n")
This way, the print("salute") and print("\n") statements will be executed 5 times as the for loop iterates 5 times. If the percent is less than 0.60, it will print "punishment" 5 times.