I am new to programming with Python and have been having non-stop issues with parts of my code being listed as unreachable. Here is my program:
def inputData():
userNumber = int(input("Please enter a number to check if it is divisible by 7 "))
return userNumber
def processData(userNumber):
return True if userNumber % 7 == 0 else False
def outputData(processData):
if True:
print("Your number IS divisible by 7!")
else:
print("Your number is NOT divisible by 7!")
def main():
userNumber = inputData()
isitdivisible = processData(userNumber)
outputanswer = outputData(isitdivisible)
print(main())
When ran it works for numbers that ARE divisible by 7 however when I input a number that isn't it gives the true output regardless. Pycharm is highlighting the else: statement as being unreadable.
Any advice on this would be greatly appreciated as I have not been able to get it to work with the use of google at all.
Aucun commentaire:
Enregistrer un commentaire