-1
import random 
print("guass a number in between 0 t0 10")
x=random.randint(0,10)
print(x)
while True:
    print=("if i have to think lower press 1,if i have to think higher press 2,if correct press 3")
    y=int(input("press your choice"))
    if y==1:
        x=random.randint(0,x)
        print(x)
    elif y==2:
        x=random .randint(x,10)
        print(x)
    elif y==3:
        print("thank you")
    else:
        print("chosee a valid no")
        break

can any 1 help me in it......

Jeff Mercado
  • 129,526
  • 32
  • 251
  • 272

2 Answers2

1

In the first iteration of your while-loop you initialize a variable named print with the value "if i have to think lower press 1,if i have to think higher press 2,if correct press 3"

I don't think you meant to do this.

print=("if i have to think lower press 1,if i have to think higher press 2,if correct press 3")

When you do this and try to call the print function, instead of it doing what you expect it to, it refers to the a string. Since a string is not a callable it throws an error.

This is a common error for new programmers run into called variable shadowing Instead try,

print("if i have to think lower press 1,if i have to think higher press 2,if correct press 3")
Skam
  • 7,298
  • 4
  • 22
  • 31
0

The reason of why you occured

TypeError: 'str' object is not callable

is print=("if i have to think lower press 1, if i have to think higher press 2,if correct press 3")`.

You call print again, from then on print is a str instead of a function.

Change:

print=("if i have to think lower press 1,if i have to think higher press 2,if correct press 3")

to

print ("if i have to think lower press 1,if i have to think higher press 2,if correct press 3")
Prashant Pimpale
  • 10,349
  • 9
  • 44
  • 84
KC.
  • 2,981
  • 2
  • 12
  • 22