def add_friend(): new_frnd = Spy("", "", 0, 0.0) new_frnd.name = raw_input('What is your name ? ') #required an input new_frnd.salutation = raw_input('what should we call you? (Mr. or Ms.)') new_frnd.age = input('What is your age ? ') #required an input new_frnd.rating = input('What is your rating ? ') #required an input new_frnd.spy_is_online = True if len( new_frnd.name ) > 2 and 12 < new_frnd.age < 50 and new_frnd.rating >= spy.rating and new_frnd.name.isalpha( ): #checking for the condition new_frnd.salutation = new_frnd.salutation.upper() friends.append(new_frnd) #appending in the list with open('friends.csv', 'a') as friends_data: writer = (csv.writer(friends_data)) writer.writerow([ new_frnd.salutation, new_frnd.name, new_frnd.age, new_frnd.rating, new_frnd.spy_is_online ]) else: print 'Sorry! You are not eligible for being a spy friend' #displaying for the user return len(friends) #returning the value for the function
elif menu_choice == 5: read_chat_history() else: show_menu = False print 'Invalid Selection' else: print 'sorry you not of the correct sage to be spy' if existing == "Y": start_chat(Spy) else: spy = Spy('', '', 0, 0.0) spy.name = raw_input("welcome to spy chat,you must tell your name first: ") if len(spy.name) > 0: spy.salutation = raw_input("what should i call you Mr or Ms? ") spy.age = raw_input("Whats your Age? ") spy.age = int(spy.age) spy.rating = raw_input("What is your spy rating? ") spy.rating = float(spy.rating) spy.spy_is_online = True start_chat(spy)