- Written by: Rama Boya
# Python program to find number of words in a sentence my_str = input("Enter a string : ") # display the original string print("The original string is : ", my_str) #find the length of split words words= len(my_str.split()) print("The number of words in given string are : ",words)
Output:
Enter a string : Rama and Vedanshi are good friends The original string is : Rama and Vedanshi are good friends The number of words in given string are : 6
- Written by: Rama Boya
Python program to display month of calendar. To do so, we need to import the calendar module which comes with Python.
Syntax:
calendar.month(year,month)
Let us see the python code to display calendar month.
# Python program to display month and year of the calendar # Import the calendar module import calendar # input month and year to display calendar yy = int(input("Enter a Year : ")) mm = int(input ("Enter a Month : ")) # Display month of the calendar print(calendar.month(yy,mm))
Output:
- Python Program to Swap Two Numbers
- Check the Minimum Angle Between Hour Hand and Minute Hand in a Clock
- Print Hello World in Python 3
- Python Code to Find All Possible Substrings in a Given String
- Python Program for Basic Calculator Operations
- Python code to calculate area of a triangle
- Python Code to Add Two Integer Numbers