initial commit
This commit is contained in:
43
schleifen/aufgabe3.py
Normal file
43
schleifen/aufgabe3.py
Normal file
@@ -0,0 +1,43 @@
|
||||
# -*- coding: ansi -*-
|
||||
import random
|
||||
|
||||
credits = 5000
|
||||
|
||||
items = {
|
||||
"sofa": 899,
|
||||
"sessel": 399,
|
||||
"couchtisch": 229,
|
||||
"tv_bank": 349,
|
||||
"b<EFBFBD>cherregal": 299,
|
||||
"beistelltisch": 119,
|
||||
"stehlampe": 189,
|
||||
"teppich": 249,
|
||||
"vorh<EFBFBD>nge": 149,
|
||||
"wandregal": 99,
|
||||
"dekovase": 59,
|
||||
"wandbild": 199,
|
||||
"kissen_set": 79,
|
||||
"decke": 69,
|
||||
"pflanzenst<EFBFBD>nder": 89
|
||||
}
|
||||
|
||||
while credits > 0:
|
||||
name, cost = random.choice(list(items.items()))
|
||||
choice = input(f"Willst du {name} kaufen um {cost}<EFBFBD>? (Y/N/S/G) ")
|
||||
|
||||
match choice.upper():
|
||||
case "Y":
|
||||
if credits >= cost:
|
||||
credits -= cost
|
||||
print(f"{name} gekauft! Verbleibendes Guthaben: {credits}<EFBFBD>")
|
||||
else:
|
||||
print("Nicht genug Guthaben!")
|
||||
case "N":
|
||||
pass
|
||||
case "S":
|
||||
print("Einkauf beendet.")
|
||||
break
|
||||
case "G":
|
||||
print(f"Du hast: {credits}")
|
||||
case _:
|
||||
print("Ung<EFBFBD>ltige Eingabe!")
|
||||
Reference in New Issue
Block a user