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 !
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 3 years ago.
Improve this question
I'm a new programmer and have no idea why this is happening.
You have some amount of spaces before the import pygame text on the first line.
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]),''))
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
How to find and replace given string from list elements?
Enumerate the list and reassign each element to be itself but with the string in question replaced by nothing.
for idx,item in enumerate(my_list):
my_list[idx] = my_list[idx].replace(removed_string, '')
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...