Question

Python Write a function named letter_function. The function should accept a string (i.e., any string) and...

Python

Write a function named letter_function. The function should accept a string (i.e., any string) and display the letters in that string. For example, if the function received "python 3.2". The following letters will be displayed: (Hint: you can use s.isalpha() to know if a character is a letter)

p

y

t

h

o

n

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def letter_function(s):
    for ch in s:
        if ch.isalpha():
            print(ch)


# Testing the function here. ignore/remove the code below if not required
letter_function("python 3.2")

Add a comment
Know the answer?
Add Answer to:
Python Write a function named letter_function. The function should accept a string (i.e., any string) and...
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
  • Write a function named mostFrequent that takes two parameters: 1. inFile, a string that is the...

    Write a function named mostFrequent that takes two parameters: 1. inFile, a string that is the name of an input file 2. outFile, a string that is the name of an output file The input file inFile exists when mostFrequent is called; mostFrequent must create outFile. The input file contains only lower case letters and white space. The function mostFrequent identifies the letter(s) that appear most frequently on each line of inFile and writes them to a corresponding line of...

  • 10. replaceSubstring Function Write a function named replaceSubstring. The function should accept three C-string or string...

    10. replaceSubstring Function Write a function named replaceSubstring. The function should accept three C-string or string object arguments. Let's call them string1, string2, and string3. It should search string for all occurrences of string2. When it finds an occurrence of Programming Challenges string2, it should replace it with string. For example, suppose the three arguments have the following values: stringt: "the dog jumped over the fence" string 2 "the" string3: "that" With these three arguments, the function would return a...

  • Write a function named vertical that accepts a string as its parameter and prints each letter...

    Write a function named vertical that accepts a string as its parameter and prints each letter of the string on separate lines. For example, a call of vertical("hey now") should produce the following output: h e y n o w

  • Using Python: #Write a letterAppearance function that takes a string, str as argument #letterAppearance will count...

    Using Python: #Write a letterAppearance function that takes a string, str as argument #letterAppearance will count the number of times each letter appears in a string #using a dictionary. #letterAppearance returns only the letters that appear in the string. #Capitalization should not matter ''' letterAppearance('hello') #{'h': 1, 'e': 1, 'l': 2, 'o': 1} letterAppearance('Hello') #{'h': 1, 'e': 1, 'l': 2, 'o': 1} letterAppearance('mutation') #{'m': 1, 'u': 1, 't': 2, 'a': 1, 'i': 1, 'o': 1, 'n': 1} '''

  • C++ Linux Compiler Letter Frequency Write a function that will take a string and return a...

    C++ Linux Compiler Letter Frequency Write a function that will take a string and return a count of each letter in the string. For example, "my dog ate my homework" contains 3 m's, 3 o's, 2 e's, 2 y's and one each of d, g, a, t, h, w, r and k. Your function should take a single string argument and return a dynamically allocated array of 26 integers representing the count of each of the letters a .. z...

  • Write a python program that will analyse the string input and print “accept” or “reject” based...

    Write a python program that will analyse the string input and print “accept” or “reject” based on the pattern given Accept if it fulfils the following conditions  String length 9  3 small alphabet (3 lowercase letter)  3 number (3 digit)  3 big alphabet (3 uppercase letters)  1 st alphabet should be capital  Last alphabet should be a number  Two consecutive alphabets can’t be small Reject if any of the condition is absent

  • project-8a Write a function named count_letters that takes as a parameter a string and returns a...

    project-8a Write a function named count_letters that takes as a parameter a string and returns a dictionary that tabulates how many of each letter is in that string. The string can contain characters other than letters, but only the letters should be counted. The string could even be the empty string. Lower-case and upper-case versions of a letter should be part of the same count. The keys of the dictionary should be the upper-case letters. If a letter does not...

  • Python please Write a function print_back_upper() that accepts a string my_str as an argument and displays...

    Python please Write a function print_back_upper() that accepts a string my_str as an argument and displays the string backwards and in uppercase, all in one line (Note: Create any necessary variables) For example: if my_str = "Python" then, your output should display as follows: NOHTYP (Hint: You can use for loop navigating up to range of len of string-1, -1, -1 and use reverse() and upper() functions to create and display the string backwards in uppercase)

  • 1.) Write a recursive function named isPalindrome that will take a single string as an argument...

    1.) Write a recursive function named isPalindrome that will take a single string as an argument and determine if the argument is a palindrome. The function must return True if the argument is a palindrome, False otherwise. Recall that any string is a palindrome if its first and last characters are the same and the rest of it is also a palindrome (therefore, a single character is a palindrome): 2.) Consider a text file named samplestrings.txt that contains a collection...

  • 1. Write a function called ordinal_sum that accepts a string argument and returns the sum of...

    1. Write a function called ordinal_sum that accepts a string argument and returns the sum of the ordinal values of each character in the string. The ordinal value of a character is its numeric Unicode code point in decimal. 2. Write code that creates a Python set containing each unique character in a string named my_string. For example, if the string is 'hello', the set would be {'h', 'e', 'l', 'o'} (in any order). Assign the set to a variable...

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