Please help me to use python write this question thanks Clas

Please help me to use python write this question, thanks.

Classes are typically between one and four credits. An advisor (who doesn\'t know how to use Excel) has been noting student credit hours as a string of numbers that you need to add up. Create a function called credit_hours that takes a string as input and adds the numbers 1-4 in the string. For example, \"4342241\" results in 20 credit hours.

Solution


def credit_hours(number):
   credit=0;
   for i in number:
       if 1<=i:
           if i>=4:
               print i;
               credit=credit+int(i);
   print credit

number=raw_input(\"Enter number\")

credit_hours(number)

Please help me to use python write this question, thanks. Classes are typically between one and four credits. An advisor (who doesn\'t know how to use Excel) ha

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site