我创建的函数在哪里出错?

时间:2019-05-14 18:47:01

标签: python-2.7 function debugging

我正在尝试用Python 2.7解决HackerRank中提到的问题。

但是当我尝试使用function方法解决问题时,它一直在出错。

请看看。我要去哪里错了?

#!/bin/python

import math
import os
import random
import re
import sys

# Complete the solve function below.
def solve(meal_cost, tip_percent, tax_percent):
    tip = float(meal_cost * (tip_percent/100))
    tax = float(meal_cost * (tax_percent/100))
    totalCost = float(meal_cost + tip + tax)
    print(int(round(totalCost)))

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

    tip_percent = int(raw_input())

    tax_percent = int(raw_input())

    solve(meal_cost, tip_percent, tax_percent)

0 个答案:

没有答案