Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Meal cost challenge
#1
I want to solve a meal cost challenge as part of learning python but when I put the following code which the website gave me, I had two problems:
import math
import os
import random
import re
import sys

# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):

if __name__ == '__main__':
    meal_cost = float(input())

    tip_percent = int(input())

    tax_percent = int(input())

    solve(meal_cost, tip_percent, tax_percent)
The first problem is: 1. My editor gave an Indentation error on the if block. It says it expected an indented block. What does that mean and how do I resolve it?
Second problem: What does the if block mean. i.e
if __name__ == '__main__':...
. What does it actually mean? In my readings I have not come across such an expression. Just a noob still therefore why I am taking the challenge to improve.
Thanks for your help.
Reply


Messages In This Thread
Meal cost challenge - by Emekadavid - Jun-01-2020, 08:54 AM
RE: Meal cost challenge - by Gribouillis - Jun-01-2020, 09:25 AM
RE: Meal cost challenge - by buran - Jun-01-2020, 11:23 AM
RE: Meal cost challenge - by Emekadavid - Jun-01-2020, 02:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Team Chooser Challenge kanchiongspider 3 2,455 Jun-02-2020, 04:02 AM
Last Post: kanchiongspider
  Appending To Files Challenge erfanakbari1 3 3,037 Mar-27-2019, 07:55 AM
Last Post: perfringo
  Problem with a basic if challenge erfanakbari1 2 2,051 Oct-12-2018, 08:04 AM
Last Post: erfanakbari1
  trying an online challenge tozqo 8 6,088 Jun-21-2017, 07:07 AM
Last Post: Kebap

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020