How the following code can be rewritten in a better way?
#!/usr/bin/env python
"""Simple program for finding popular names
over last 100 years, in response to vegaseat's
last post in Projects for Beginners(9/1/2012).
It first lists the popular names and then search
for entered name by user"""
oldnames = """Mary,Helen,Margaret,Anna,Ruth
Elizabeth,Dorothy,Marie,Florence,Mildred
Alice,Ethel,Lillian,Gladys,Edna
Frances,Rose,Annie,Grace,Bertha
Emma,Bessie,Clara,Hazel,Irene
Gertrude,Louise,Catherine,Martha,Mabel
Pearl,Edith,Esther,Minnie,Myrtle
Ida,Josephine,Evelyn,Elsie,Eva
Thelma,Ruby,Agnes,Sarah,Viola
Nellie,Beatrice,Julia,Laura,Lillie
Lucille,Ella,Virginia,Mattie,Pauline
Carrie,Alma,Jessie,Mae,Lena
Willie,Katherine,Blanche,Hattie,Marion
Lucy,Stella,Mamie,Vera,Cora
Fannie,Eleanor,Bernice,Jennie,Ann
Leona,Beulah,Lula,Rosa,Ada
Ellen,Kathryn,Maggie,Doris,Dora
Betty,Marguerite,Violet,Lois,Daisy
Anne,Sadie,Susie,Nora,Georgia
Maude,Marjorie,Opal,Hilda,Velma"""
newnames = """Emily,Madison,Emma,Hannah,Abigail
Olivia,Ashley,Samantha,Alexis,Sarah
Elizabeth,Isabella,Alyssa,Grace,Lauren
Taylor,Jessica,Brianna,Kayla,Sophia
Anna,Natalie,Victoria,Chloe,Sydney
Jasmine,Hailey,Megan,Rachel,Morgan
Julia,Destiny,Ava,Jennifer,Kaitlyn
Mia,Katherine,Alexandra,Haley,Savannah
Nicole,Maria,Allison,Mackenzie,Stephanie
Brooke,Amanda,Ella,Makayla,Faith
Kaylee,Jenna,Andrea,Katelyn,Mary
Jordan,Gabrielle,Rebecca,Paige,Madeline
Kimberly,Trinity,Zoe,Michelle,Sara
Lily,Kylie,Alexa,Caroline,Vanessa
Amber,Angelina,Gabriella,Lillian,Riley
Sierra,Danielle,Leah,Jada,Autumn
Erin,Maya,Ariana,Audrey,Isabel
Sofia,Marissa,Bailey,Jacqueline,Melissa
Claire,Evelyn,Shelby,Jocelyn,Mariah
Avery,Leslie,Melanie,Arianna,Aaliyah"""
old_names = [name.lower() for name in (oldnames.replace("\n", ",").split(","))]
new_names = [name.lower() for name in (newnames.replace("\n", ",").split(","))]
def find_name():
print "Popullar names in last 100 years:"
for name in new_names:
if name in old_names:
print name
print "*"*50
name = raw_input("Enter a name:").lower()
if (name in old_names) and (name in new_names):
print name, "is still a popullar name over 100 years"
elif (name in old_names) and not (name in new_names):
print name, "is an old name"
elif (name in new_names) and not (name in old_names):
print name, "is a new name"
else:
print name, "is not in the lists"
find_name()