Considering the example below, why would anyone choose the first print instead of the second?
def main():
name = input("Input your name:")
age = int(input("Input you age:"))
print("Your name is " + name + " and you are " + str(age) + " years old.")
print("Your name is", name, "and you are" , age, "years old.")
if __name__ == "__main__":
main()
It seems to me that print("text", var, "text") is more straightforward, since there's no need to explicitly convert our int to str.
Are there any relevant use cases for the print("text"+str(var)+"text") format?
The usual way of doing this is formatting like:
Well, the first way (concatenation of strings and expressions converted to strings) is obsolete and unusable for me, since we have proper formatting (like my example above). We can construct any string we want straightforwardly and clearly.
If we apply the same logic to
*argsapproach, as for me, the outcome is the same.