年金公式的未来值不起作用

问题描述 投票:-1回答:1

这是我到目前为止所拥有的:

P_s= input("Enter Periodic Payment>")
r_s = input("Rate per Period (Enter as a decimal please)> ")
t_s = input("Number of Periods>")

# Using len() and conditionals to check inputs
if len(P_s) == 0 or len(P_s) > 4:
    print("Must enter a number between 1 and 4 characters for Periodic Payment, please try again")
    exit(0)

if float(r_s) == 0.00 or float(r_s) > 1.00:
  print("Must enter a number between 0.01 and 1.00 for Rate per Period, please try again")
  exit(0)

if len(t_s) == 0 or len(t_s) > 2:
  print("Must enter a number between 1 and 2 characters for Number of Periods, please try again")
  exit(0)

# Check for Raw Input for Valid Characters 
if P_s[0] not in ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',] :
  print("Not in list")
else:
  print("Continue")
  exit()

通过检查原始输入部分,P_s在标识符中说出无效字符。有人知道如何解决吗?

python if-statement conditional-statements formula
1个回答
0
投票

我不知道这是否是您的问题,但这可能是列表中的多余逗号:“'9']”

© www.soinside.com 2019 - 2024. All rights reserved.