小编Dav*_*man的帖子

Python意外的indentaton错误main()

我不知道如何解决这个问题.我试过重新输入程序.

我的最后一个主函数出现了意外的缩进错误.

resident = 81
nonresident = 162


def main():

    # initialize counters and total tuition
    resident_counter = 0
    nonresident_counter = 0
    total_tuition = 0

    print("Name \tCode\tCredits\tTuition")
    print

    try:
        # open the data file
        infile = open('enroll.txt', 'r')

        # read the first value from the file
        student_name = infile.readline()

        # continue reading from file until the end
        while student_name != '':

            # strip the new line character and print the student's name
            student_name = student_name.rstrip('\n')
            print(student_name, end='\t')

            # read the …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

3
推荐指数
2
解决办法
783
查看次数

标签 统计

python ×1

python-3.x ×1