Hi
the print shows only the text, but not the result.
This works= print(topay)
Thanks for help.
import datetime
begdat = input("begindate (dd-mm-jj): ")
enddat = input("enddate in (dd-mm-jj): ")
db=datetime.datetime.strptime(begdat,"%d-%m-%y").date()
de=datetime.datetime.strptime(enddat,"%d-%m-%y").date()
x=int(input("amount persons: "))
d=de-db
topay=(d.days + 1) * 15 * x
print(("You have to pay: ").format(topay)) # only text is shown
Tuhin PaulPosted Mar 18, 2023, 6:27 PM
Instead of using "You have to pay: ", you should use "You have to pay: {}" so that the result of topay gets inserted into the string.
Try changing the last line to:
Valerie MeunierPosted Mar 18, 2023, 9:54 PM
Yes, of course. Stupid question. Thanks
Tuhin PaulPosted Mar 18, 2023, 6:26 PM
I think you're missing the placeholder in the format string for the
topayvariable..