Created
March 30, 2017 10:21
-
-
Save NimJ/45ccfb541439e882988a079cd3e8b195 to your computer and use it in GitHub Desktop.
Revisions
-
NimJ created this gist
Mar 30, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ Class a: def cow_bull(self): import random cowbull = [0,0] count = 1 x = random.sample([1,2,3,4,5,6,7,8,9,0],4) y = list(input('input 4 digits seperated by spaces \n ')) while x != y: for i in range(3): if y[i] in x: if y[i] == x[i]: cowbull[0] += 1 else: cowbull[1] += 1 print '{0} cows and {1} bulls'.format(cowbull[0], cowbull[1]) y = list(input('input 4 digits seperated by comma \n ')) cowbull = [0, 0] count += 1 print 'you won with {0} guesses'.format(count) if __name__ == '__main__': a = A() a.cow_bull()