Dictionary of names and birthdays This code is to have a dictionary of names and birthdays.

It will ask who's birthday it is that you're looking for. Then if it is in the dictionary, it will print back what that birthday is. If not, it will ask if you want to add it then have you insert the birthday as the value and use the name that you input before as the key. Then finally print the full dictionary. 

I am pretty new to coding in Python and feel like there is a better way to type this code. Was thinking I could use return but I'm still not quite sure what the difference between return and print is. Is there a way to make this shorter or more efficient? 

birthdays = {'Jon': 'July 17', 'Shauna': 'Jan 27', 'Lynette': 'July 10'}

while True:
    print("Who's birthday is it that you are looking for? To cancel, press enter!")
    name = input()
    if name == '':
        break

    if name in birthdays:
        print(birthdays[name] + ' is the birthday of ' + name)
    else:
        print("I don't have that person's name in my archives. Would you like to add it? Press Y or N")
        answer = input()
        if answer == 'Y':
            new_name = name
            print("Please enter their birthday")
            new_birthday = input()
            birthdays[name] = new_birthday
            print('It has been added')
            print(new_name + "'s birthday has been added as " + new_birthday)
            print('Here is a list of birthdays you have saved...')
            print(birthdays)
        else:
            print('Alrighty Then')
return returns the value, in this case the dictionary birthdays, whereas print just prints the value to the terminal. Your printing might be improved by using f-strings. This is usually a bit easier than having to use "+" inside your print statements. So for example, instead of 

print(new_name + "'s birthday has been added as " + new_birthday)


You could write:

print(f"{new_name}'s birthday has been added as {new_birthday}")


This combined with a generator could also make your dictionary printing a little neater:

print("\n".join([f"{name}'s birthday is {bday}" for name,bday in birthdays.items()]))


The generator creates a list of strings for each item in the birthdays dictionary, so in this case, it would generate the list ["Jon's birthday is July 17","Shauna's birthday is Jan 27", "Lynette's birthday is July 10"]. The join() function is used to combine each element of this list into a new string, separated by the newline character \n. So the final result would produce:

Jon's birthday is July 17
Shauna's birthday is Jan 27
Lynette's birthday is July 10


If you want to further extend this code, I'd recommend representing the birthday as a date object, from the Python built-in library datetime. Then you could also add the functionality of easily telling how many days until someone's birthday and other features like that.