This is an example of defining a function that takes a parameter.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
You rolled: 5 4 5 3 3 +---+ |o o| | o | |o o| +---+ +---+ |o o| | | |o o| +---+ +---+ |o o| | o | |o o| +---+ +---+ |o | | o | | o| +---+ +---+ |o | | o | | o| +---+ You rolled: 2 2 5 5 5 +---+ |o | | | | o| +---+ +---+ |o | | | | o| +---+ +---+ |o o| | o | |o o| +---+ +---+ |o o| | o | |o o| +---+ +---+ |o o| | o | |o o| +---+ // skip a whole bunch of rolls You rolled: 3 3 3 3 3 +---+ |o | | o | | o| +---+ +---+ |o | | o | | o| +---+ +---+ |o | | o | | o| +---+ +---+ |o | | o | | o| +---+ +---+ |o | | o | | o| +---+ The Yacht!!
So explanation yet, sorry. Hopefully the code is enough. If you're already this far into the assignments, the code is probably enough.
So, did you catch that on line 17? In a lot of programming languages, you can only compare things in pairs. So you would have to do something like this: if r1 == r2 and r2 == r3 and r3 == r4 and r4 == r5:
Python is totally okay with comparing a bunch of things at once, though. It's handy.
- Add a sixth dice.
©2017 Graham Mitchell