Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I guess it's about print
#1
code:

money=1000
取款=int(input('请输入取款金额:'))
if 取款<=money:
    print('请拿好钞票',取款)
    print('账户余额为:', money = money-取款)
else:
    print('余额不足,现有:', money)
    print('请再次输入取款金额:')
result
Error:
请输入取款金额:350 请拿好钞票 350 Traceback (most recent call last): File "E:\2018.1.1\Python\4 if.py", line 5, in <module> print('账户余额为:', money = money-取款) TypeError: 'money' is an invalid keyword argument for print()
so when print, money = money - withdraw is causing trouble, right?
buran write Feb-07-2021, 02:59 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.

You already have been advised to do so.
Reply
#2
(Feb-07-2021, 02:41 PM)tsavoSG Wrote: money = money - withdraw is causing trouble, right?
yes
print('账户余额为:', money-取款)
you better look at f-strings or str.format methods
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
I think the problem is you cant do a calculation where you put it,
so put the calculation money = money-取款
on a separate line and it appears to work:

money=1000
取款=int(input('请输入取款金额:'))
if 取款<=money:
    print('请拿好钞票',取款)
    money = money-取款
    print('账户余额为:', money)
else:
    print('余额不足,现有:', money)
    print('请再次输入取款金额:')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Guess the word game help jackthechampion 3 3,025 Sep-06-2023, 06:51 AM
Last Post: Pedroski55
  Ask again if wrong guess with While. EduPy 4 2,251 Oct-21-2021, 07:46 PM
Last Post: menator01
  can't figure out problem with number guess Galoxys 4 3,347 Oct-29-2018, 01:45 PM
Last Post: snippsat
  Guess a number Ameen 5 13,124 Apr-03-2018, 01:20 PM
Last Post: snippsat
  Guess Random Number Why i m not able to enter input Nithya Thiyagarajan 6 8,202 Jan-07-2018, 04:26 AM
Last Post: squenson
  "Guess the Number" game CTT 14 13,343 Jul-26-2017, 11:41 AM
Last Post: sylas

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020