Sorry if this is a newbie question I was wondering why I was getting the error "TypeError: unsupported operand type(s) for &: 'float' and 'float'" whenever I ran my program which is supposed to try to guess my number by picking the amount of numbers I tell it to (precision variable) and average the numbers in a 3 number radius to get a number close to mine. Feel free to suggest more efficient ways of writing my code I just began learning Python...
__author__ = 'Vansh'
import random
def avg(*args, length):
nums = 0
for num in args:
nums += num
return nums/length
def standby():
i = input(">>> ")
if i != "close":
standby()
def ai():
x = float(input("Enter A Number: "))
y = int(input("Enter Precision: "))
z = []
for i in range(y*5):
random_guess = random.randrange(-1, 101)
decimal = random.randrange(-1, 10)
random_guess = float(random_guess + (decimal/10))
while random_guess > x-3 & random_guess < x+3:
print()
z.append(random_guess)
print("Number Guess: {}".format(avg(z, len(z))))
standby()
ai()