Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python lambda printing space

Tags:

python

lambda

In python I want a lambda which return space characters equal to the input. for example.

x=lambda x: return space x times
print "my message",x(10),"my message 2"

Output:

my message<10 space>my message 2

This will cater my need in a particular situation. I can write a function for this but if this could be done?

like image 273
MYNE Avatar asked Jul 16 '26 19:07

MYNE


1 Answers

Something like:

x = lambda times:' '*times
print "my message{0}my message 2".format(x(10))         
my message          my message 2
like image 56
iabdalkader Avatar answered Jul 18 '26 07:07

iabdalkader



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!