We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,574 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

how to compare 2 str in python

how can i compare 2 string for bull hit game in python.
i wrote the program itself.
how can i find how many hits and bulls i have.

import string
import random
import re

m = input (' Please input the long of the string you want to guess :')
m= int(m)
a = string.ascii_lowercase
b = ''.join(random.choice(a) for x in range(m))
print(b)
print ('now you can start guessing')
z = input ('input your guess :')

while  b != z:
        if len(b) != len(z):
                print(' please enter a guess with the same lenght')
                print(' *reminder: its a',m,'letters long')
                z = input ('input another guess :')
        else:
               for i in str(z) 
                print('you got $S pulls and $S hits')
                print(' Guess Again')
                z = input ('input another guess :')
else:
                print('nice guess')
1
Contributor
0
Replies
1
View
Shady Baddarni
Newbie Poster
1 post since Nov 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0592 seconds using 2.65MB