Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on Why are commas not needed for modulo string formatting when printing?
Post
Why are commas not needed for modulo string formatting when printing?
+6
−3
Suppose I have two variables that are called animal
and age
, and print them as a string in the console like so:
animal = "giraffe"
age = 25
print("A %s can live up to %d years" %(animal,age))
Why shouldn't there be a comma between the string and the %(animal,age)
part? Does Python automatically detect that it needs two parameters to execute?
1 comment thread