Welcome to Westonci.ca, your one-stop destination for finding answers to all your questions. Join our expert community now! Our platform provides a seamless experience for finding reliable answers from a network of experienced professionals. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
Sagot :
The code to calculate the number of characters and the size of words is as follows:
x = input("Enter your text here: ")
char=0
word=1
for i in x:
char = char+1
if(i==' '):
word=word+1
print("Number of words in the given string ",word)
print("Number of characters in the given string ",char)
Code explanation:
The code is written in python
- The first line of code, we store the users input in a variable called x.
- Then we initialise the variable char to zero.
- The variable word is also initialise to zero
- The we loop through the user's input and count the character
- We also look for space to know the word, then count the words .
- Finally, we print the number of word and the number of character.
learn more on python code here: https://brainly.com/question/20379340
Thank you for choosing our service. We're dedicated to providing the best answers for all your questions. Visit us again. Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Westonci.ca is your go-to source for reliable answers. Return soon for more expert insights.