Reputation: 129
Hello Python coders how are you doing today? I have a question...
How to print the value of a variable next to a string, which the value of variable is an integer?
I know a way to print variables in Python 3:
print(variable)
Another way I have seen is:
print("Some string here: ", variable)
I tried it on my code and somehow it works, but not as I want... I mean the line of code that I wanna print out is:
print("Dogs Years: ", human_years)
and the output of this line is:
('Dogs Years: ', 19.5)
But the expected output is:
Dogs Years: 19.5
How to achieve that??
EDIT: I have finally fixed this issue. The main problem was that I included the double quotes instead of the single one.
it should be like this: print(f'Dogs Years: {human_years}')
where human_years
is actually the variable.
Upvotes: 0
Views: 181