How to delete an empty line after using input()
in python.
annual_salary = int(input("Enter your annual salary:"))
portion_saved = float(input("Enter the percent of your salary to save, as a decimal:"))
I'm unsure what you are asking, the code seems to work fine without an empty line:
Read up the documentation about input()
: https://docs.python.org/3/library/functions.html#input
input( [prompt] )
If the prompt argument is present, it is written to standard output without a trailing newline.
So if you do not want an empty line, make sure to add in a prompt.
See Possible to get user input without inserting a new line? if your issue is the newline after people inserted a value.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.