'none' 无缘无故打印

'none' prints for no apparent reason

print("Entre nummber 1: ")
num1 = float(input('> '))
print("Entre opperation: ")
op = input('> ')
print("Entre nummber 2: ")
num2 = float(input('> '))
result = print("Your Result is:")

if op == "+":
    print(num1 + num2)
    print(result)
    print("Done")

elif op == '-':
    print(num1 - num2)
    print(result)
    print("Done")

elif op == '/':
    print(num1 / num2)
    print(result)
    print("Done")

elif op == '*':
    print(num1 * num2)
    print(result)
    print("Done")
elif op == '**':
    print(num1 ** num2)
    print(result)
    print("Done")
else:
    print("Entre a valid opperation")

我试着做了一个计算器。它工作正常,但最后会无缘无故弹出 'none'。

我不知道为什么。感谢任何帮助。

问题是这样的:

result = print("Your Result is:")

print("Your Result is:") 打印此字符串 "Your Result is:" 和 returns None 现在 result 等于 None。然后 print(result) 打印 None

result = print("Your Result is:")

printreturn没什么None

结果值为 None

print(result) #this is none

你应该把它存储在像

这样的变量中
result = num1 + num2
print(result) #with calculated value
# remove result = print("Your result is :")
# Add this result = num1 'operation +/-/*/** etc' num2 after your if condittions.
# for example :
if op == "+":
    result = num1 + num2
    print("Your result is :",result)
if op == "-" :
    result = num1 - num2
    print("Your result is :",result)
# It will work fine.