human
Count number of ways to cover a distance | Set 2 | Function to return the count of the total number of ways to cover the distance with 1 , 2 and 3 steps.
Base conditions.
To store the last three stages.
Find the numbers of steps required to reach the distance i.
Return the required answer.
Driver code"
How can the above be solved in Python?

What is a code to count number of ways to cover a distance and the other steps required?
assistant
#Here is code to count number of ways to cover a distance and the other steps required.
 def countWays ( n ) :
	if ( n == 0 ) :
		return 1
	if ( n <= 2 ) :
		return n
	f0 = 1
	f1 = 1
	f2 = 2
	ans = 0
	for i in range ( 3 , n + 1 ) :
		ans = f0 + f1 + f2
		f0 = f1
		f1 = f2
		f2 = ans
	return ans
n = 4
print ( countWays ( n ) )