Question: Solve this feedback error. Change my python code to solve this. Please look at picture below. Question Goal: Learn to use loops together with variables

Solve this feedback error.
Change my python code to solve this.
Please look at picture below.
Question
Goal: Learn to use loops together with variables to accumulate a result.
Assignment Assume that n is assigned a positive integer. Write code using the while loop to assign to total the sum of the firt n whole numbers as followe
If the number is even, halve and add its
If the number is odd, add it.
For example, if n is 5, total will be 1+(22)+3+(42)+5=12
Reminder. Whole numbers are 1,2,3,dots (and so on).n=5
total =0i =1while i }=n\mathrm{ :
if i %2==0: # Check if the number is even
total t= i /2 # Halve the even number and add to total
else: # The number is odd
total t= i # Add the odd number to total
i t=1 # Increment the counterprint(f"The total is: {total}")
More information
The * total * iss *12,0
Feedback:
(P The expected value for 'total' was 1 but actual is 12.0
Solve this feedback error. Change my python code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!