I'm working on a mini horoscope theme-based project where I ask for the users' birth day and month and as a result output their zodiac sign. So far my code is simply printing the day and month and my entire CSV file. I'm trying to print the specific outcome based on what the user enters. Here's what I have so far.
import csv
def main():
fields = []
rows = []
with open('TableHoroscope.csv', 'r') as csvfile:
csvreader = csv.reader(csvfile)
fields = next(csvreader)
for row in csvreader:
rows.append(row)
print("Num of rows:", csvreader.line_num)
print('Field names are:' + ', '.join(field for field in fields))
user_birthday()
print_zodiac(rows)
def print_zodiac(rows):
for row in rows[:13]:
for col in row:
print(col)
print('')
def user_birthday():
date = int(input("Enter date:"))
month = input("Enter month:")
print('Birthday: ' + str(date) + month)
print('')
main()
Here is a text version of my CSV file
SIGN,START,END
Aries,21-Mar,19-Apr
Taurus,20-Apr,20-May
Gemini,21-May,20-Jun
Cancer,21-Jun,22-Jul
Leo,23-Jul,22-Aug
Virgo,23-Aug,22-Sep
Libra,23-Sep,22-Oct
Scorpio,23-Oct,21-Nov
Sagittarius,22-Nov,21-Dec
Capricorn,22-Dec,19-Jan
Aquarius,20-Jan,18-Feb
Pisces,19-Feb,20-Mar
I would really like help on how to approach this. I'm limited to what I can do with my code considering I need to have four def functions and no global variables and I'm still a beginner. Thank you!