def get_weekdays_for_subject(subject):
    weekdays = []
    with open("input/timetable.csv",encoding="utf-8") as f:
        for row in f:
            colums = row.rstrip().split(",")
            day = colums[0]
            if row.find(subject) >= 0:
                weekdays.append(day)
    return weekdays


def main():
    subject = '理科'
    weekdays = get_weekdays_for_subject(subject)
    print("「{}」は{}にあります".format(subject,",".join(weekdays)))


if __name__ == '__main__':
    main()




----------------
def count_subjects():
    pass
    s_count = {}
    with open('input/timetable.csv', encoding='utf-8') as f:
        for row in f:
            columns = row.rstrip().split(",")
            day = columns[0]
            for col in columns:
                if col != day:
                    if col in s_count.keys():
                        s_count[col] += 1
                    else:
                        s_count[col] = 1
    return s_count



def main():
    subject_counts = count_subjects()
    for subject, count in subject_counts.items():
        pass
        print('{}は{}回'.format(subject, count))

if __name__ == '__main__':
    main()



----------------------
def replace_subject(row, week_day, p_sub, a_sub):
    pass
    if row.startswith(week_day):
        return row.replace(p_sub, a_sub, 1)
    else:
        return row 

def main():
    with open('input/timetable.csv', encoding='utf-8') as f:
        for row in f:
            new_row = replace_subject(row, '月曜日', '体育', 'ダンス')
            print(new_row, end='')


if __name__ == '__main__':
    main()




月曜日,国語,算数,社会,体育,体育
火曜日,算数,外国語,理科,国語,音楽
水曜日,体育,社会,家庭,国語,算数
木曜日,国語,図画工作,理科,算数,国語
金曜日,算数,社会,体育,理科,生活