+ 10

Python help needed please [solved]

In this code, i want random keys to be printed from the dictionary, and the user must input the value of that key. Please help me do this. https://code.sololearn.com/c5oq1hRB3113/?ref=app

31st Aug 2021, 3:19 AM
Anas Dharar
Anas Dharar - avatar
8 ответов
+ 6
https://code.sololearn.com/cb0ONTA1XTKc/?ref=app check this out please
31st Aug 2021, 3:24 AM
Vtec Fan
Vtec Fan - avatar
+ 3
But Rushikesh , what about answers? If i want answer from user.... What should i do?
31st Aug 2021, 3:31 AM
Anas Dharar
Anas Dharar - avatar
+ 3
Oh thanks a lot Rushikesh ! Thank you
31st Aug 2021, 3:38 AM
Anas Dharar
Anas Dharar - avatar
+ 2
Anas (50% Active) Please have a look again
31st Aug 2021, 3:35 AM
Vtec Fan
Vtec Fan - avatar
+ 2
Easy 🤗🤗🤗 quizs = dict() seen = list() while True: # bag data struct impl using dict+set quiz, answer = random.choice(quizs.items()) if quiz in seen: continue # avoid ask for dupes seen += quiz # register dupe if len(seen) > len(quizs): break # all seen. end game #... ask user user_answer = input(quiz) #... check user answer print("You win" if answer is user_answer else "You loose") is all you need
31st Aug 2021, 2:32 PM
David Ordás
David Ordás - avatar
+ 1
⠀⠀⠀ if You learning the dictionarys You can use glichs for
31st Aug 2021, 1:28 PM
CGO!
CGO! - avatar
+ 1
use this to make it generate diffrent questions every time: import random def generate_sheet(howlong): out = dict() for i1 in range(howlong): ques = '{}{}{}'.format( str(random.randint(10,500)), random.choice(list('+-')), str(random.randint(10,500)),) ans = eval(ques) out[ques] = ans return out #this function returns a dict use it like this questions = generate_sheet(howlong=10)
31st Aug 2021, 10:42 PM
⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀ - avatar
0
If this is solved.... remember mark a response as valid
31st Aug 2021, 3:44 PM
David Ordás
David Ordás - avatar