Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
![](/static/devrant/img/pipeless-devrant-banner-white.png)
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@shelladdicted My function was written in python 3... And why did you add semicolons?
-
@AlgoRythm ok, so I was not clear enough.
1)python3 allows semicolons so it's not a SyntaxError.
2)your function doesn't support text format (%d,%.1f in C/C++) that in python3 are replaced by {0}
the function that @sid-maddy provied supports that so it's a bit better.
i wrote python(3) because in python2 {0} is replaced by % -
@shelladdicted
1) Just because a language allows it doesn't mean you should do it. You shouldn't.
2) (see attached) -
@AlgoRythm i just saw the screenshot in python(3) use {0} instead of %d etc....
see docs for format of strings.
name="AlgoRythm";
printf("Hello {0}!",name); #// yes i use ; and // ;-) (joking)
#another way
text = "hello {0}".format(name);
print(text); -
@shelladdicted Yeah, still not sure what you're going at, but whatever. I understand string formatting. The % operator works in both 2 and 3 and works with tuples and shit too.
An interesting python function I just made. Probably not the first to do so.
def printf(fmt, *args):
print(fmt, args, end="")
rant