Random number generator returning duplicate values

I have a random number generator I want to return 7 keys from a dictionary. I am using random.uniform to generate a float value which I match to my set of values in my dictionary which are float values to produce the closest value and return the relevant key to that value. I am iterating… Read More Random number generator returning duplicate values

How do I get my random password generator in Python to work?

I’m in a college class for programming and I have to make a random number generator using Python, but I can never seem to get it to work. I either get an error or nothing gets displayed. Currently the error I’m getting with this version is line 34, in <module> print(rand.randchoice(X) in range(Y)) return seq[self._randbelow(len(seq))]… Read More How do I get my random password generator in Python to work?

What is wrong with my code? It just randomly stops

This is the code, but I see no mistake. It is supposed to be a simple guessing game. import random a=random. randint(1, 10) b=random. randint(11, 20) guess_count=0 print(‘Hello, pick a number from ‘+str(a)+’ ‘+’to ‘+str(b)+’.’) number=int(input()) guess=random. randint(a, b) while number < guess: print(‘Number too low. Guess again: ‘) number=int(input()) guess_count+=1 while number > guess:… Read More What is wrong with my code? It just randomly stops

nested strings for random.choice python

I have 4 lists and want to choose a random list and then choose a random item of it. this is my code but it doesn’t work properly. can you help please? import random w=[‘*’, ‘&’ ,’^’, ‘%’ ,’$’ ,’#’, ‘@’ ,’!’] w1=[‘w’,’a’,’s’,’r’,’i’,’t’,’e’,’n’,’d’,’c’] w2=[‘W’,’A’,’S’,’R’,’I’,’T’,’E’,’N’,’D’,’C’,] w3=[‘1′,’2’] p=” j=8 while j: e=random.choice([‘w’,’w1′,’w2′,’w3′]) q=random.choice(f'{f"{e}"}’) p+=q j-=1 print(p) and… Read More nested strings for random.choice python