I am trying to create a game that will ask the user to make a guess and if the guess is lower than the randomly generated integer, then it'll print ('Too low! Try again.), if the guess higher than the guess then it will print ('Too high! Try again) and if guess is equal to the random integer then it will ask the user if she wants to play again. This is where I am having trouble with - how can I have the code loop it back to recreate the random integer and start the loop if 'y' is entered?
import random
def main():
again='y'
count=0
while again=='y':
print('I have a number between 1 to 1000.')
print('Can you guess my number?')
print('Please type your first guess')
number=random.randint(1, 1000)
print(number)
guess=int(input(''))
while guess !='':
if guess>number:
print('Too high, try again!')
count+=1
print('count:',count)
guess=int(input(''))
elif guess<number:
print('Too low, try again!')
count+=1
print('count:',count)
guess=int(input(''))
elif guess==number:
print('Excellent!! You guessed the number!!!!')
print('Would you like to try again? (y or n)')
count+=1
print('count:',count)
again=str(input(''))
else:
print('You entered an invalid value')
main()