Skip to content
Advertisement

Tag: python-3.x

How to check if a string is a palindrome?

I have a code to check whether a word is palindrome or not: If a word is inputted, for example : rotor , I want the program to check whether this word is palindrome and give output as “The given word is a palindrome”. But I’m facing problem that, the program checks first r and r and prints “The given

Preferred way of resetting a class in Python

Based on this post on CodeReview. I have a class Foo in Python (3), which of course includes a __init__() method. This class fires a couple of prompts and does its thing. Say I want to be able to reset Foo so I can start the procedure all over again. What would be the preferred implementation? Calling the __init__() method

Namespaces inside class in Python3

I am new to Python and I wonder if there is any way to aggregate methods into ‘subspaces’. I mean something similar to this syntax: I am writing an API wrapper and I’m going to have a lot of very similar methods (only different URI) so I though it would be good to place them in a few subspaces that

Python – Send item to next page in Word

I am trying to send text to the next page in a .docx file using Python. So far, I have written a some code that will locate a certain word in a .docx file (using python-docx): Now I want to send each occurrence of “Hello” to a new page so that each page in my Word document starts with the

How can one list item have 2 indexes?

Suppose that I write a list: foo=[1,2,3,4,5,6,7,8,9,1] When I try to find out the index of 1 in foo, it comes out to be 0. But I wanted to find the index of the 1 at the last ( it’s expected index is 9 ) so I wrote this simple code that would give me all the indexes of all

Advertisement