Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ Please ensure your pull request adheres to the following guidelines:
- Check your spelling and grammar.

Thank you for your suggestions!

Beautiful is better than ugly. / Simple is better than complex.
26 changes: 26 additions & 0 deletions lab2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import random

weapons = ["Fist", "Knife", "Club", "Gun", "Bomb", "Nuclear bomb"]
print("Weapons: ", weapons)

try:
weaponRoll = random.randint(1, 6)
print(f"Weapon roll: {weaponRoll}")

hero_weapon = weapons[weaponRoll - 1]
print(f"Your hero's weapon: {hero_weapon}")

if weaponRoll <= 2:
print("You rolled a weak weapon, friend.")
elif weaponRoll <= 4:
print("Your weapon is meh.")
else:
print("Nice weapon, friend!")

if hero_weapon != "Fist":
print("Thank goodness you didn't roll the Fist..")

except IndexError as e:
print(f"Error: {e}")
except Exception as e:
print(f"An unexpected error occurred: {e}")