Monday, February 4, 2019

codingdirectional: Sum of all the non-negative and non-zero numbers in a list

Hello, we are supposed to start a new project today but because I am busy doing something else, therefore, I only post a simple solution for one of the questions on codewars. We will start our next python project in the next chapter.

Codewars is the place you all will want to visit to brush up your python skill if you are really serious about learning python. Although some questions on codewars are really tricky and some of them make people hard to understand but overall speaking this is the only place which provides real deal for those python programmer who wants to perfect their python skill. If you find out that some questions on codewars have provided a wrong answer and make your head spins like crazy then just ignore that one and move on to the next one instead.

Given a list of numbers, return the total of those positive numbers.

def positive_sum(arr):
    sum = 0
    for i in arr:
        if(i > 0):
            sum += i
    return sum

Here you have it, a short answer to the above python question. We are relaxing today but in the next chapter onward thing will become complicated once we have started our next python project. Do like and share the below tweet on this post and do follow me on twitter from the below twitter widget. We can talk more about python on twitter.



from Planet Python
via read more

No comments:

Post a Comment

TestDriven.io: Working with Static and Media Files in Django

This article looks at how to work with static and media files in a Django project, locally and in production. from Planet Python via read...