NB: Always read the fucking manual the instruction to not cast/print the number as a string but rather an integer was in the question, but I totally ignored it and it took me hours to get the right code. I had to check a friend's
"You are not allowed to cast the variable number into a string" -> that was the instruction
number = 98
print(f"{number:d} Battery street")
not adding just ":d" was what made the checker flag me wrong
print(f"{number} Battery street")
: In this case, the variable number is used directly in the f-string without any format specifier. Python automatically converts the value of number to its default string representation. This means that the value of number is converted to a string implicitly before it is concatenated with the rest of the f-string.
print(f"{number:d} Battery street")
: Here, :d
is a format specifier used in the f-string. It explicitly specifies that the value of number should be treated as an integer (d stands for "decimal"). Python converts the value of number to an integer and then formats it as a string with the specified format.