amt = float(input("Please enter the amount to make change for: $"))
Run Code Online (Sandbox Code Playgroud)
我希望用户以美元输入金额,因此允许5个字符(00.00)有没有办法限制它,所以它不允许他们输入超过5个字符?
我不想要这样的东西,它允许你输入超过5但会循环.
while True:
amt = input("Please enter the amount to make change for: $")
if len(amt) <= 5:
print("$" + amt)
break
Run Code Online (Sandbox Code Playgroud)
我希望完全限制输入超过5个字符
python ×1