Question

Please create a function with python to read a mixed numeric/alphabetic (strings) list and then outputs...

Please create a function with python to read a mixed numeric/alphabetic (strings) list and then outputs the following: The sum of the numeric values in the list
A count of the non-numeric values in the list

Homework Answers

Answer #1
def printCounts(mystr):
        total=0
        count=0
        for c in mystr:
                if c.isdigit():
                        total+=int(c)
                else:
                        count+=1
        print("Sum of numeric digits: ",total)
        print("Count of non numeric letters: ",count)

s=input("Enter string: ")
printCounts(s)

Note : Please comment below if you have concerns. I am here to help you

If you like my answer please rate and help me it is very Imp for me

Know the answer?
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
Similar Questions
Write a Python function first_chars that takes one parameter, which is a nested list of strings....
Write a Python function first_chars that takes one parameter, which is a nested list of strings. It returns a string containing the first character of all of the non-empty strings (at whatever depth they occur in the nested list) concatenated together. Here are a couple of examples of how the function should behave when you're done: >>> first_chars(['Boo', 'is', 'happy', 'today']) 'Biht' >>>first_chars(['boo', 'was', ['sleeping', 'deeply'], 'that', 'night', ['as', ['usual']]]) 'bwsdtnau'
** Language Used : Python ** PART 2 : Create a list of unique words This...
** Language Used : Python ** PART 2 : Create a list of unique words This part of the project involves creating a function that will manage a List of unique strings. The function is passed a string and a list as arguments. It passes a list back. The function to add a word to a List if word does not exist in the List. If the word does exist in the List, the function does nothing. Create a test...
Create a function which returns the number of odd integers in a list (python)
Create a function which returns the number of odd integers in a list (python)
Use python def a function that takes in a list of passwords (as strings), a password...
Use python def a function that takes in a list of passwords (as strings), a password that needs to be checked (as a string), and an integer that represents the number of repetitions. If the given password occurs given number of times, return True, else return False. eg. >>> repeats(["ma48", "ma28", "ma48"], "ma48", 2) True >>> repeats(["ma48", "ma28", "ma48"], "ma48", 3) False >>> repeats(["ma48", "ma28", "ma48", "ma28", "ma48"], "ma38", 2) False >>> repeats(["ma48", "ma28", "ma48", "ma38"], "ma48", 1) False
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
solve in python 3.8 please The question is about Strings Modify your function so that it...
solve in python 3.8 please The question is about Strings Modify your function so that it can handle the following two situations: The string given as an argument has no characters. In this case, you should return the empty string. The string given as an argument has one character. In this case, you should return the one-character string given to you. Without any consideration for these cases, your function probably causes an error or returns the wrong result in the...
[Python] Write a function named "total_population" that takes a string then a list as parameters where...
[Python] Write a function named "total_population" that takes a string then a list as parameters where the string represents the name of a CSV file containing city data in the format "CountryCode,CityName,Region,Population,Latitude,Longitude" and the second parameter is a list where each element is itself a list containing 3 strings as elements representing the CountryCode, CityName, and Region in this order. Return the total population of all cities in the list. Note that the city must match the country, name, and...
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b....
1-Create a week_tuple and assign the days of the week as strings to the week_tuple. b. Print out the elements in the week_tuple. 2-a. The following list has been declared as follows: credit_list = [24,3,15] b. Convert the credit_list to a tuple named credit_tuple. c. Print out the elements in the credit_tuple. 3-a. Write an initialize_list_values function that takes in a number for the number of elements in a list and an initial value for each element. The function creates...
Python pls create a function called search_position. This function returns a list of 2 tuples and...
Python pls create a function called search_position. This function returns a list of 2 tuples and the number should be start highest number. The first index is the number, and second are list of 2 tuples that sorted by position in alphabetical order: The first index will be position and second index will be champion's name(This also should be sorted by alphabetical order). team1 = {'Fiora': {'Top': 1, 'Mid': 4, 'Bottom': 3},'Olaf': {'Top': 3, 'Mid': 2, 'Support': 4},'Yasuo': {'Mid': 2,...
Python. create a function that takes a string as a parameter and prints out the following...
Python. create a function that takes a string as a parameter and prints out the following details as the example output below. If the string is "Hello, my name is Starling, Clarice. My, my, my, nice to meet you." The output would be: Unique words: 10 Number of commas: 5 Number of periods: 2 Number of sentences: 2 (HINT: Use the following string methods: split, lower, count, replace, format, and use the following functions: set, len. You may need to...