<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Pratik Kinage</title>
    <description>The latest articles on DEV Community by Pratik Kinage (@thirstycode).</description>
    <link>https://dev.to/thirstycode</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F676313%2F25d7fab9-e46a-4322-9422-125b95536f00.jpeg</url>
      <title>DEV Community: Pratik Kinage</title>
      <link>https://dev.to/thirstycode</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thirstycode"/>
    <language>en</language>
    <item>
      <title>Python Program to Get the Month Name When Number is Entered By User</title>
      <dc:creator>Pratik Kinage</dc:creator>
      <pubDate>Thu, 29 Jul 2021 11:45:16 +0000</pubDate>
      <link>https://dev.to/thirstycode/python-program-to-get-the-month-name-when-number-is-entered-by-user-mol</link>
      <guid>https://dev.to/thirstycode/python-program-to-get-the-month-name-when-number-is-entered-by-user-mol</guid>
      <description>&lt;p&gt;Python Program to Get the Month Name When Number is Entered By User&lt;/p&gt;

&lt;h3&gt;
  
  
  Code:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while True:
    try:
        num = int(input("Enter month number : "))
        break
    except:
        print("Invalid input")

if num == 1:
    print("Month is January")
elif num == 2:
    print("Month is February")
elif num == 3:
    print("Month is March")
elif num == 4:
    print("Month is April")
elif num == 5:
    print("Month is May")
elif num == 6:
    print("Month is June")
elif num == 7:
    print("Month is July")
elif num == 8:
    print("Month is August")
elif num == 9:
    print("Month is September")
elif num == 10:
    print("Month is October")
elif num == 11:
    print("Month is November")
elif num == 12:
    print("Month is December")
else:
    print('Invalid number')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Output:
&lt;/h3&gt;

&lt;p&gt;Enter month number : 5&lt;br&gt;
Month is May&lt;/p&gt;

&lt;h3&gt;
  
  
  Explanation:
&lt;/h3&gt;

&lt;p&gt;In the above Program to Get the Month Name When Number is Entered By &lt;a href="https://www.pythonpool.com/python-user-input/"&gt;User Input&lt;/a&gt;. We have used the while loop. And to manage the exceptional handling we have used the try-except block.&lt;br&gt;
try-except block is also used here because if the user entered something else rather than integer number it will print Invalid input.&lt;/p&gt;

&lt;p&gt;In the try block, we are taking the input of type integer as the program is to Get the Month Name When Number is Entered By User.&lt;/p&gt;

&lt;p&gt;After the end of the while loop, we will get a valid input. Then we further process the input with the conditional statements. The if-elif-else statements are the conditional statements in Python.&lt;/p&gt;

&lt;p&gt;So First we check if the input is equal to 1. In Python to check the statement we use ‘==’. And to assign we use ‘=’.&lt;/p&gt;

&lt;p&gt;If the user has inputted 1 then the output will be Month is January and the &lt;a href="https://www.pythonpool.com/python-exit/"&gt;program will terminate&lt;/a&gt;. And if the inputted number is not 1 it will go to the second elif statement. The process will go on till the input integer matched with the conditional statement.&lt;/p&gt;

&lt;p&gt;If none of the inputted integers matched it will return Invalid Number.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
