Hi bvdet
The goal here is to accept input from the user and create a list. Then you will add the elements of the list to a set. If the set size increases, add the word to a dict with the word being a key and the value being the length of the set, which is also the number of
pairs in the dict at the time it was added. In psuedocode, you will need something like:
for each word in the input text:
set...
User Profile
Collapse
-
How to work with sets and dicts in Python?
Hello Guys!
I need to create a program similar to this explanation
I am new to Python so for me it's very...Code:for each word in the input text: set a variable equal to the length of the set add word to the set if the length of the set is greater than the length of the "old" set: add the word to the dict for k, v in words.items(): print(k, v) -
I haven't seen ctr yet but I tried it and it worked.
Thank youLeave a comment:
-
How to limit the amount of inputs(guesses)
Hello guys and thank you in advance for reading my post.
I am writing the following module which will ask the end-user to guess a number and after x amount of guesses a message should appear to says "Sorry, you have tried x times already"
This is what I have so far.
...Code:n = 56 while True: guess = int(input("Guess a number: ")) if guess > n:
No activity results to display
Show More
Leave a comment: