My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

How to disable auto spacing in Python ?

M. Saeb's photo
M. Saeb
·Feb 21, 2019

For this code:

books = ["Romance","Drama","Horror"]
for number, book in enumerate(books):
    print (number+1 , ".", book)

I want to get the output:

1.Romance 2.Drama 3.Horror

but I'm getting this instead:

1 . Romance 2 . Drama 3 . Horror

I tried using sys.stdout.write() instead of print() but I'm getting an error that say "expected a string or other character buffer object"

please tell me how do I disable this auto spacing thing, thanks in advance 🤚😁