Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 5 years ago.
Improve this question
My questions refers to a "concatenation" of a Python dictionary. For example: I have a dictionary di = {1:'AB', 2:'BC',3:'CD'}, and I want with one command print(____) to get the output 'ABCD'.
Any suggestions?
Try This One.
print(''.join(str(e) for e in list(sorted(set(di[1]+di[2]+di[3]))))
Hope that this is what you wanted
di = {1:'AB', 2:'BC',3:'CD'}
print((di[1]+di[2]+di[3]).replace((di[2]),''))
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
For example, when I tried to get the user's username, this happens: Hello, [{'users': 'username'}]
How can I remove the rest, and get only the username?
appreciate the help!
Your question isn't clear
So, in order to get the username. First we need to iterate. Like this:
val = [{'users': 'username'}]
for values in val:
print(values["users"])
So this prints the 'username' in the dictionary.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I have a feature named "Address" which has 65000 records. Each row has data, for example:
5-54,8th block,Koramangala,Bengaluru
I want to access only 'Koramangala'.
How can I do this?
Use Series.str.split with select last but one value by indexing [-2]:
df['new'] = df['Address'].str.split(',').str[-2]
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
How do I config my vscode output to look like the first image?
What I want:
What it actually looks like:
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I have a passage. Is there a way from which I could scramble the words from the passage?
First, create a list with all the words of the passage.
If you have the text in another file, use "readlines" and "for" to iterate over it.
Then, use something like:
import random
List_Of_Words = ["these","are","the","words"]
random.shuffle(List_Of_Words)
Hope this helps !
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I would need something like
{"a"=1,"b"=2,"c"=3,"d"=4}
but python is not able to decode it, it gives me an error message. is there a way around that?
thank you
Replacing the "=" with ":" should work...