Last answered:

31 May 2022

Posted on:

30 May 2022


Resolved: print('\'',num,'\'', 'is not a number')

Good morning, I have this question: if I write the code "print('\'',num,'\'', 'is not a number')", the risult is, for example, ' cat ' is not a number.  How can I avoid the spaces between quotes and "cat"? Thank you

2 answers ( 1 marked as helpful)
Posted on:

31 May 2022


Hey Alessandro,

Thank you for your question!

You can avoid the spaces by concatenating the strings using a plus sign as follows:

print('\'' + num + '\'' + ' is not a number')

Notice that I've added an additional space at the beginning of the last string.

Another way to solve the task is by using f-strings. The solution would look as follows:

print(f'\'{num}\' is not a number')

Hope this helps!

Kind regards,
365 Hristina

Posted on:

31 May 2022


Thank you very much

Submit an answer