Count Even Numbers User has Inputted PYTHON 3

前端 未结 5 1183
死守一世寂寞
死守一世寂寞 2021-01-24 03:11

I must create two functions. One that can tell whether one number is odd or even by returning t/f, and the other will call the first function then return how many even numbers t

5条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-24 03:46

    d = input("Please enter more than one number: ")
    

    This is going to return a string of numbers, perhaps separated by spaces. You'll need to split() the string into the sequence of text digits and then turn those into integers.


    There's a general approach to determining whether a number is odd or even using the modulus / remainder operator, %: if the remainder after division by 2 is 0 then the number is even.

提交回复
热议问题