All Courses

Getting error

By Pp5344229@gmail.com, 3 months ago
  • Bookmark
0

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

Error
If
Else
Conditional statements
Python
Indentationerror:
2 Answers
0
Hitendradixit18@gmail.com

Hit tab before print salute, and print punishment

0
Goutamp777

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.

Your Answer

Webinars

Live Masterclass on : "How Machine Get Trained in Machine Learning?"

Mar 30th (7:00 PM) 516 Registered
More webinars

Related Discussions

Running random forest algorithm with one variable

View More