1

This is Guess_The_Number program I wrote in Python:

import random
print("Hello! Today we are going to play Guess The Number!")
number = int(input("Guess a number between 0 and 5"))
random_number = random.randint(0, 5)
if number == random_number:
    print("You won!")
    print("Your prize is...")
    print("Nothing!")
else:
    print("You lost!")
    print("The number was %s") % (random_number)

I tested it and it returned:

print("The number was {0}").format(random_number)
AttributeError: 'NoneType' object has no attribute 'format'

Then I tried:

print("The number was {0}").format(random_number)

for the last print statement

It stated:

print("The number was {0}").format(random_number) AttributeError: 'NoneType' object has no attribute 'format'
A MUSE
  • 35
  • 6

1 Answers1

2

You have misplaced parenthesis

print("The number was {0}".format(random_number))

SMALL NOTE - It works in Py2

EDit - I meant your program works in Py2 that is ("The number was {0}").format(random_number) works in Py2

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140