Skip to main content
How are we doing? Please help us improve Stack Overflow. Take our short survey

All Questions

Tagged with
-1 votes
1 answer
38 views

Python search for the errors in the JSON

Premise: those dictionaries are strings. Those are JSON with a bad format. I search for the errors inside those JSON and print them. example 1: input { "ced": { "CED_PH2&...
user3084383's user avatar
1 vote
1 answer
58 views

Why is my code not displaying firstNotRepeatingCharacter in the string, in Python?

So, I am solving this code signal problem and it's problem statement is as follows Given a string s consisting of small English letters, find and return the first instance of a non-repeating ...
vilnius19's user avatar
  • 115
0 votes
1 answer
32 views

if statement homework error, how do i fix it? [duplicate]

I have some intro to python homework I can't seem to get right. The question is : "Write a program to determine how much to tip the server in a restaurant. The tip should be 15% of the check, ...
drc91's user avatar
  • 5
0 votes
0 answers
334 views

Porting Python2 to Python3 - Reading Bytes from a socket and using unpack() correctly

There is code here that I am trying to convert from Python2 to Python3. In this section of code, data is received from a socket. data is declared to be an empty string and then concatenated. This is ...
Ascor's user avatar
  • 11
0 votes
1 answer
79 views

Can you change the string of an instanced string class

I have this class: class A(str): def __str__(self): return "the string" def __repr__(self): return "the repr" a = A("change me") ...
Adam Sirrelle's user avatar
0 votes
0 answers
63 views

Can you set the instance of an Object Class as a string input

Can you set the object class return as a string? I have tried setting the object class with the __str__ and __repr__ methods overwritten. class A(object): def __str__(self): return "...
Adam Sirrelle's user avatar
0 votes
2 answers
43 views

code for Addition three minus one variable numbers

How to get from a list [7,0,8] from [7, 0, 8]? in python This is my code l3=input() l5=l3.translate({Ord("["):None}) l1=l5.translate({Ord("]"):None}) l6=input() l7=l6.translate({...
SAJJA PUSHYANTH RA191100301061's user avatar
-2 votes
2 answers
872 views

Fill in the gaps in the initials function so that it returns the initials of the words contained in the phrase received, in upper case

#original code def initials(phrase): words = phrase.___ result = "" for word in words: result += ___ return ___ print(initials("Universal Serial Bus&...
amalkishore's user avatar
0 votes
1 answer
44 views

Change url formatting in Jupyter Python

Hey im trying to change 2 parts of a string, first is the last char, second in the mid of the string: *nkw= will be cat: "sport , elec..." *pgn= 1 , 2, 3, 4 .... there is 2 loops because i ...
OmerB's user avatar
  • 19
-1 votes
2 answers
79 views

how to compare given date (string) is current date to last 8 date or not? [closed]

I have an one date in a string. How can I figure out this date REFRESH = ("2021-11-25 00:27:23") to current date from last 8 days from datetime import datetime from datetime import ...
Ajith MsM's user avatar
1 vote
4 answers
669 views

How can i remove only the last bracket from a string in python?

How can i remove only the last bracket from a string ? For example, INPUT 1: "hell(h)o(world)" i want this result: "hell(h)o" Input 2 :- hel(lo(wor)ld) i want :- hel as you ...
officialrahulmandal's user avatar
0 votes
2 answers
386 views

Get all rows in a Pandas DataFrame column that are in a list of strings - This pattern has match groups

Consider the code import pandas as pd # dfs df_sample = pd.read_csv('...........') array = ['' , '' , '' ....] pattern = '|'.join(array) # get all the rows print(df_sample.COLUMN_NAME_XXX.str....
JAN's user avatar
  • 21.9k
0 votes
0 answers
17 views

When I run this python command in the interpretor, I get a TypeError [duplicate]

So I was running the command 'first={0[0]}, last={0[-1]}'.format(somelist) where somelist = ['s','p','a','m']. I get an error which says TypeError: list indices must be integers or slices, not str. ...
Harry Karwasra's user avatar
0 votes
2 answers
78 views

Python 2.7 fnmatch NOT editing text

I have a file with 600k+ records of string labels I am trying to edit with an update cursor using both the string modules and fnmatch to find patterns to edit. The section using fnmatch is ...
Cödingers Cat's user avatar
0 votes
1 answer
789 views

Python Conversion of Generic list to List[str] (Python 2.7)

I am facing an issue with my code. Where I need to extract a list of strings from dictionary (returned by method 1) and pass it as parameter to method 2. viewerIDs = Parent.GetViewerList() if (len(...
Tamil Ninja's user avatar

15 30 50 per page
1
2 3 4 5
74