Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 17, 2021 05:05 am GMT

X-Mas Wisher in python

Intro

Hello everyone sorry for the late post as you might now that I am a student so that's why I got loads of classwork to do that's why this post is late . So as you know that X-Mas / Christmas is coming close so in today's post I will be telling you how to make an X-Mas Wisher in Python.

Let's Get started !

Importing the required modules

main.py

#Making an X-Mas Wisher using python#importing the required modulesimport random

For printing the wishes we also need a file which contains wishes so first create a file named wishes.txt

Wishes.txt

Happy X-MasSanta Claus is coming with some exciting gifts!Wishing you a Christmas that's merry and bright!I hope your holiday season is full of peace, joy and happiness!Merry Christmas with lots of loveI hope your Christmas is filled with joy this year!May this season find you among those you love, sharing in the twin glories of generosity and gratitude.Christmas is not an external event at all, but a piece of ones home that one carries in ones heart.We clap hands and welcome the Peace of Christmas.We beckon this good season to wait a while with us.Christmas isnt just a day. Its a frame of mind.Wishing you a season thats merry and bright with the light of Gods love.Christmas gives us an opportunity to pause and reflect on the important things around us.

Now we will open the file and choose a random line to print from it

#opening and reading the filelines = open('wishes.txt').read().splitlines()#using random to choose any random line from the fileWish = random.choice(lines)#printing the lineprint(Wish)

Now with this done we have successfully created a X-Mas Wisher in python.

I hope you enjoyed this post.
feel free to write down your suggestions/doubts in the comments section and comment "X-Mas Yaay!" if you see this

That's it for today, stay safe and do take very good care of yourselves.
Thanks


Original Link: https://dev.to/spandyboss/x-mas-wisher-in-python-1f5d

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To