Create An Invitation Card - Python

Updated: a day ago


Suppose it's your birthday and you need to create an invitation. Let's see how we can do that using the python function.


In this program, we will learn to create reusable code with functions and make personalised invitation cards using function parameters. We will be using concepts as indicated in the concepts covered.


If you wish to learn the concepts and see the detailed steps to arrive at the solution, refer to my video on youtube



Concepts Covered


python function, parameters, default parameter values, f-string, multiline string with triple quotes, for with list, string split



Problem Description


The program should create a personalised invitation message for 5 different persons with the following message


  Dear <guestname>,
    Please come to my birthday party
    Venue-<venue name>
    Date-<date of birthday>
    Time-<time of party>
  Host Name


How It Should Work



Approach


  1. Create a function birthdayInvite which accepts parameters - guestName, venue,day,time,hostName

  2. Give default value to parameters like venue,day,time,hostName

  3. Inside the function, use triple quotes and f-string to create an invite message using params

  4. Outside the function prompt user to enter guest names separated by a comma & save it in a string

  5. Create a guest list by splitting the above string taken from the user

  6. Use for loop to create invitation card by calling the function.


Solution