Question

Write a program that asks the user to enter a string and then asks the user...

Write a program that asks the user to enter a string and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the string.

python programming

0 0
Add a comment Improve this question Transcribed image text
Answer #1
s = input("Enter string: ")
ch = input("Enter character: ")
count = 0
for x in s:
    if(ch==x):
        count+=1
print("The number of times that the specified character appears in the string is",count)

Add a comment
Know the answer?
Add Answer to:
Write a program that asks the user to enter a string and then asks the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • ***** JAVA ONLY ***** Write a program that asks the user to enter the name of...

    ***** JAVA ONLY ***** Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad to create a simple file that can be used to test the program. ***** JAVA ONLY *****

  • USING PYTHON PROGRAMING LANGUAGE Write a program that first asks the user to enter a “special”...

    USING PYTHON PROGRAMING LANGUAGE Write a program that first asks the user to enter a “special” letter. The program should then ask the user to enter a single line sentence containing all lowercase letters and no punctuation, except for a period at the end. The program will then output the number of times that this letter appears in the sentence. Example: Enter a special letter: t Enter a sentence: here is my little sentence. Your letter appears 3 times. (t...

  • Write a program in python that asks the user to input a sentence. The program will...

    Write a program in python that asks the user to input a sentence. The program will ask the user what two letters are to be counted. You must use a “for” loop to go through the sentence & count how many times the chosen letter appears in the sentence. You are not allowed to use python built-in function "count()" or you'll get a Zero! Output will show the sentence, the letter, and the number of times the letter appears in...

  • Objectives: Use strings and string library functions. Write a program that asks the user to enter...

    Objectives: Use strings and string library functions. Write a program that asks the user to enter a string and output the string in all uppercase letters. The program should then display the number of white space characters in the string. You program should run continuously until the user enters an empty string. The program must use the following two functions: A function called count_spaces that counts the number of white spaces inside a string. int count_space(char str[]); which tell you...

  • MIPS programming question Problem 1: Write a program that asks the user to input a string...

    MIPS programming question Problem 1: Write a program that asks the user to input a string (or no more than 50 characters). Your program should then output the length of the string. The string length should be determined using a separate function strlen that will accept the address of the string and return its length. For the purposes of this exercise, the length of a string will be defined as the number of non-null and non-newline characters until either the...

  • PYTHON: write a program that lets the user enter a sting and displays te character that...

    PYTHON: write a program that lets the user enter a sting and displays te character that appears most frequently in the string. A space can be the most frequent in the string, but do not include it for the count. (Please make it as simple as possible, I just started learning python)

  • Write a program that asks the user to input the number of males and females registered...

    Write a program that asks the user to input the number of males and females registered in a class (Max 30 members in the class). The program should display the percentage of males and females in the class. Python programming question

  • Python: Write a program that lets the user enter a string and displays the letter that...

    Python: Write a program that lets the user enter a string and displays the letter that appears most frequently in the string, ignore spaces, punctuation, and Upper vs Lower case. Create a list to hold letters based on the length of the user input Convert all letters to the same case Use a loop to check for each letter in the alphabet Have a variable to hold the largest number of times a letter appears, and replace the value when...

  • Python Programming 4th Edition: Write a program that asks the user for the number of feet....

    Python Programming 4th Edition: Write a program that asks the user for the number of feet. The program converts those feet to inches by using the formula ’12 * feet’. Hint: Define main () program Get the number of feet from the user Define variables Call a function feet_to_inches(feet) The function receives the number of feet and returns the number of inches in that many feet. The output should look like as follows: Enter the number of feet: If the...

  • Write a program that asks the user to enter a number ofseconds.• There are...

    Starting Out with C++ (9th Edition)  Chapter 4, Problem 7PCWrite a program that asks the user to enter a number of seconds.• There are 86400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86400, the program should display the number of days in that many seconds.• There are 3600 seconds in an hour. If the number of seconds entered by the user is less than 86400, but is greater...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT