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?