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
In Python, write a function that takes in an arbitrary list of numeric triples (tuples of...
In Python, write a function that takes in an arbitrary list of numeric triples (tuples of size 3), and returns a new list containing the maximum elements from each
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'
Python coding: HW `declaration.py` * define function `calc_histogram(lines)` * returns histogram dictionary and total non-whitespace characters...
Python coding: HW `declaration.py` * define function `calc_histogram(lines)` * returns histogram dictionary and total non-whitespace characters * takes list of strings as argument * ignore comment lines denoted by `#` * if invoking script directly, load `data/declaration.txt` and calculate histogram * print histogram by sorted characters * count letter instances not characters, so `A` and `a` count as same (This is the local test I was given): if __name__ == '__main__': import os.path file_path = os.path.join("data", 'declaration.txt') print(file_path) letter =...
Write a Python function that takes two parameters: the first a list of strings and the...
Write a Python function that takes two parameters: the first a list of strings and the second a single string. The function should return True or False depending on whether the string is in the list or not. For example, if the list contains eggs, milk, bananas, and the second parameter is pumpkin, the function should return False. Thank you.
Write a Python function that takes two parameters: the first a list of strings and the...
Write a Python function that takes two parameters: the first a list of strings and the second a single string. The function should return True or False depending on whether the string is in the list or not. For example, if the list contains eggs, milk, bananas, and the second parameter is pumpkin, the function should return False. Thank you.
Write a Python function that takes two parameters: the first a list of strings and the...
Write a Python function that takes two parameters: the first a list of strings and the second a single string. The function should return True or False depending on whether the string is in the list or not. For example, if the list contains eggs, milk, bananas, and the second parameter is pumpkin, the function should return False. Thank you.
Write a Python function that takes two parameters: the first a list strings and the second...
Write a Python function that takes two parameters: the first a list strings and the second a single string. The function should return True or False depending on whether the string is in the list or not. For example, if the list contains eggs, milk, bananas, and the second parameter is pumpkin, the function should return False.
** 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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT