Python sep= ", " But Only Want It 2nd Time Onwards -
so making basic text game progress learning python. offer choices trying print choices list , have these lines of code:
hubchoices = ["fight","shop","upgrade stats"]
print("you can,"hubchoices[0].capitalize(),,hubchoices[1].capitalize(),hubchoices[2].capitalize(), sep= ", ")
the output receive this:
you can, fight, shop, upgrade stats
is there way have sep= ", " work after first comma more this:
you can fight, shop, upgrade stats
(and way capitalize first letter of every word .capitalize())
try str.join
:
print("you can %s" % ','.join([c.capitalize() c in hubchoices]))
Comments
Post a Comment