Skip to main content

All Questions

Tagged with
-1 votes
1 answer
33 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
0 votes
0 answers
14 views

Python2 unable to pickle string

This link says that both normal and unicode strings can be pickled. But when I try following, def __del__ (self): with open(self._pkl, 'wb') as f: pickle.dump(dict(self._rec), ...
Sourav Kannantha B's user avatar
1 vote
1 answer
41 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
28 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
1 answer
39 views

Change order of characters in string randomly keeping the format in python [closed]

I have to mask some data but it is important to keep the format of it. So I have differents strings like: x = "0 1-111-555" y = "000000-2022-1000253" z = "01-702-1424" t =...
Jordi Lazo's user avatar
0 votes
0 answers
310 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
59 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
0 votes
1 answer
108 views

String comparison in tuple or list. Python2 vs Python3

We all probably agree that to compare two strings: var = "MyString" print(var is "MyString") # This is not the way we would do it (we don't what to compare the ID) print(var == &...
Roure Ossó's user avatar
-2 votes
2 answers
871 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
41 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
78 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
0 votes
2 answers
47 views

Replace a certain part of the string which matches a pattern in python 2.7 and save in the same file

I am trying to achieve something of this sort My input file has this kind of entries art.range.field = 100 art.net.cap = 200 art.net.ht = 1000 art.net.dep = 8000 I am trying to match the pattern like ...
Saswata Kar's user avatar
1 vote
4 answers
587 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

15 30 50 per page
1
2 3 4 5
95