Answered You can hire a professional tutor to get the answer.
I have a question in my assigned practice that is not working and I'm not sure what I'm missing. I'm not getting syntax errors just traceback calls...
I have a question in my assigned practice that is not working and I'm not sure what I'm missing. I'm not getting syntax errors just traceback calls and type errors. Here is the question:
Implement a Python function called count_pos that takes a list of numbers as input (parameter) and returns the number of elements of that list that are positive (> 0). Then, in the main portion of your program should ask the user to input the list, then it should call count_pos function with that list, and print the result. You may assume that the user will always enter at least two elements, but your function count_pos should work for all lists of numbers including those of length 0 and 1.
Here is what I have so far:
def count_pos(l):
count=0
for i in l:
if i>0:
count = count+1
print ("There are" + count +"positive numbers in your list.")
def main():
s = input('Please input a list of numbers: ')
l = list(eval(s))
count_post(l)
What is the correct way to define these functions?