Skip to content

Tag: python-3.x

how does replace function work in python 3.x

I am new to Python, I read in a book that strings are immutable. Then how does replace() function work in Python? Does it slice up to the part where it finds the text that we want to replace and add the text with new string and then add the remaining text which is after the text we want to

Drawing Semi-Circles in Pygame

Is there a way to draw a semicircle in Pygame? Something like this: pygame.surface.set_clip() will not work for this – I need circles that look like pie slices as well, like this one: Answer PyGame has no function to create filled arc/pie but you can use PIL/pillow to generate bitmap with pieslice and c…

Writing To CSV file Without Line Space in Python 3

I am trying out the program for writing to a CSV file. Here’s my code: The program runs well. But in the CSV file, there is a blank newline space (without any entries) between each entry. How to eliminate that line in the resultant CSV file? Answer Recommended implementation per Python3 Documentation. h…