무엇이 python에서이 오류가 발생합니까?Python 오류 'str'객체에 'randrange'속성이 없습니다.
Traceback (most recent call last):
File "F:/coding/python/python programming for absolute beginners/chapter 4/
The Jumble Game.py", line 9, in <module>
p=random.randrange(len(word))
AttributeError: 'str' object has no attribute 'randrange'
코드 : 이름을 밖으로 거기에서 random
참조 문자열 객체가 아닌 모듈을
random=""
:
import random
print"\t\t\tThe Jumble Game"
print"In this program you will be given a jumble word and you have to guess that word"
set=("book","parrot","rabbit")
word=random.choice(set)
random=""
jumble=""
while(word):
p=random.randrange(len(word))
random=random+word[position]
word=word[:position]+word[(position+1):]
print("The jumble word is",random)
빈 문자열 변수가 포함 된 임의의 모듈을 가리십시오. –
@EricLeschinski : 아니요, 이름은 같은 범위에있는 * 리바운드 *입니다. –