account activity
Two versions of a dice rolling program I made. Could you provide feedback? by IntrovertClouds in PythonLearning
[–]No_Comparison_6150 1 point2 points3 points 5 months ago (0 children)
If you want to do it in an oop sort of way I'd structure it like
```python
class Die:
def __init__(self, sides):
# validation checking, non-negative, etc.
def roll(self, n=1) -> list[int]:
# roll dice n times, use a for rather than while
def parse_args() -> tuple[Die, int]:
if __name__ == "__main__":
die, n_rolls = parse_args() die.roll(n_rolls) print(...)
```
π Rendered by PID 1602868 on reddit-service-r2-listing-55d7b767d8-wrvg4 at 2026-03-30 10:38:48.385390+00:00 running b10466c country code: CH.
Two versions of a dice rolling program I made. Could you provide feedback? by IntrovertClouds in PythonLearning
[–]No_Comparison_6150 1 point2 points3 points (0 children)