- Home
- Course Category
- Course Result
- Course Detail
Hot Line: 08377052947
-
TeacherJyoti
-
Category
Programming, Website Development
-
Duation
15 hours
-
Reviews(117 review)
-
Call Us for Details
Basic Python Course Questions
Python programming language is a general-purpose, dynamic programming Language.Python language have a large library of packages which makes python for beginners a language of choice.
Programs for practice
In the program below, we used the for loop wot count the words and charcters in a string.
Source Code:
PROGRAM TO CALCULATE THE NUMBER OF WORDS AND THE NUMBER OF CHARACTERS PRESENT IN A STRING IN PYTH
ON
# CALCULATE THE NUMBER OF WORDS AND THE NUMBER OF CHARACTERS PRESENT IN A STRING
string=input("Enter string:")
char=0
word=1
for i in string:
char=char+1
if(i==' '):
word=word+1
print("Number of words in the string:")
print(word)
print("Number of characters in the string:")
print(char)
Output
Run the program to see the output