lundi 31 juillet 2017

How to generate random string?

I'm super new in Python coding or i mean every coding. I just want to ask that like taking random number from: Random.randint(a, b)

I just want to ask that how to take random string just like randint but this time with random string. Is there anyway?

Please help me. I'm new in this world and Sorry for my bad english.

#This program will play a little game

import random

a = ''
b = ''
c = ''
d = ''
e = ''
f = ''

print('Hi. Please enter your name in letters')
name = str(input())
print('Hi ' + name + '. I am going to play a little game. In this game you have to guess a specific name i am thinking right now.')
print('But do not worry. I am going to let you to enter 6 names and i will choose one of them.')
print('After that you have to answer the correct name that i am thinking right now')
print('Please enter the first name in letters')
name1 = str(input())
print('Please enter the second name in letters')
name2 = str(input())
print('Please enter the third name in letters')
name3 = str(input())
print('Please enter the fourth name in letters')
name4 = str(input())
print('Please enter the fifth name in letters')
name5 = str(input())
print('Please enter the sixth name in letters')
name6 = str(input())
name1 = a
name2 = b
name3 = c
name4 = d
name5 = e
name6 = f

print('Alright ' + name + ' . Thank you for entering the names.')
secretname = random.randint(a, f)
for i in range(2):
        print('Now enter the name that i am thinking of.')
        ans = str(input())
        if ans != secretname:
                print('Wrong. Guess another name')

if ans == secretname:
        print('Good job ' + name)
else:
        print('Wrong. The name i was thinking of was ' + secretname)

This is a little game which request from you to enter 6 names and then the game will guess a number between those 6 numbers you have entered but it always gaves me an error. So.. please help me. I want to do it with random string. Help!




Aucun commentaire:

Enregistrer un commentaire