Go Fish/Python: Difference between revisions

m
Fixed syntax highlighting.
No edit summary
m (Fixed syntax highlighting.)
 
(One intermediate revision by one other user not shown)
Line 3:
===OOP===
{{works with|Python|2.5}}
<langsyntaxhighlight Pythonlang="python">import random
import sys
from collections import defaultdict
Line 143:
if __name__=="__main__":
game = PlayGoFish()
game.play()</langsyntaxhighlight>
 
===Procedural===
{{works with|Python|3.6}}
<syntaxhighlight lang="python">"""
<lang Python>"""
Plays a Go Fish game between a user and computer
following the rules specified at
Line 451:
if asked_card in hand:
return asked_card
print("You don't have that card. Try again!")
"Try again! (or enter quit to exit)")
 
 
Line 502 ⟶ 501:
 
if __name__ == "__main__":
play()</syntaxhighlight>
</lang>
9,482

edits