'AttributeError: module 'rules' has no attribute 'fizz'
So I tried to create a fizz buzz game code in python and I wanted to import the rules from another file,
import rules
fizz = rules.fizz
buzz = rules.buzz
fizzbuzz = rules.fizzbuzz
def fizz_buzz(input):
if input % fizz == 0:
result = "Fizz"
elif input % buzz == 0:
result = "Buzz"
elif input % fizzbuzz== 0:
result = "Fizzbuzz"
else:
result = input
return result
i = 1
while i < 1000:
print(fizz_buzz(i))
i += 1
fizz = 3
buzz = 5
fizzbuzz = fizz*buzz
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
