I have this code:
print("Christian Dooley")
print("Lab #5")
import sys
def calculation():
counter = 0
NumberOfElements = 1
numbers = []
sum = (0)
for i in range(NumberOfElements):
value=eval(input("Enter a new number:"))
numbers.append(value)
while counter <= value:
print(counter)
sum+=counter
counter+=1
if counter % 2 != 0:
print("This number is even")
else:
print("This number is odd")
print(sum)
while True:
calculation()
repeat = input("Do you want to 'count' another number \n Awnser yes or no: ")
if repeat == "Yes" or "yes":
calculation()
elif repeat == str("no") or str("No"):
break
When the code runs, it should ask the user to input a number; print every number leading up to it; tell if the number is even or odd; print the sum; and finally have the user enter if he wants to repeat the process or not.
This part of the code is giving me trouble:
if repeat == "Yes" or "yes":
calculation()
elif repeat == str("no") or str("No"):
break
The if statement will keep running over and over, no matter what I enter for the repeat variable. Why does this happen?