for answer in QF:
ans = "{:.2f}".format(answer)
if ans in "0.00j":
print(ans.replace("0.00j", ""))
else:
print(ans)
If there is 0.00j in the answer, I have to delete it and print it out, so I used the replace function You keep saying
Calculated answer is(are): -3.73+0.00j -0.27-0.00j
This is how 0.00j is printed. What's the problem? Python masters, help!
python
The third line, if an "0.00j": is if an "0.00j" in an: Please change it to
You used the replace function normally, but it is a matter of condition that the function is not operated.
So the overall code should be changed as below
for answer in QF:
ans = "{:.2f}".format(answer)
if "0.00j" in ans:
print(ans.replace("0.00j", ""))
else:
print(ans)
565 PHP ssh2_scp_send fails to send files as intended
580 GDB gets version error when attempting to debug with the Presense SDK (IDE)
558 Who developed the "avformat-59.dll" that comes with FFmpeg?
560 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
820 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.