python - str object not callable when converting int variable to using str function -


i'm sorry if asked have been sifting through past questions , cannot seem find answer. new @ python too.

what trying write word , r , c variable output file formatted space between word , variable (the format being longest word of list - word looking at).

i have tried this, yet comes "str object not callable"

row_variable = str(r) 

here traceback when tried it:

traceback (most recent call last): file "c:\cs303e\wordsearch.py", line 106, in <module>   main () file "c:\cs303e\wordsearch.py", line 84, in main   output.write(list_of_words[i]+spaces+str(row_variable)+str(column_variable)) typeerror: 'str' object not callable 

here code:

# find longest word in list of words max_length = 0 in list_of_words:   if len(i) > max_length:     max_length = len(i) # open output file found.txt output = open('found.txt','w')  # check list of words in range(len(list_of_words)):   flag = false   j in range(len(rows)):     if list_of_words[i] in rows[j]:       r = j + 1       c = rows[j].find(list_of_words[i]) + 1       num_spaces = max_length - len(list_of_words[i])       spaces = ' ' * num_spaces       output.write(list_of_words[i])       flag = true   j in range(len(rev_rows)):     if list_of_words[i] in rev_rows[j]:       r = j + 1       c = num_col - rev_rows[j].find(list_of_words[i])       print(list_of_words[i], r, c)       flag = true   j in range(len(columns)):     if list_of_words[i] in columns[j]:       r = j + 1       c = columns[j].find(list_of_words[i]) + 1       print(list_of_words[i], c, r)        flag = true   j in range(len(rev_columns)):     if list_of_words[i] in rev_columns[j]:       r = j + 1       c = num_col - rev_rows[j].find(list_of_words[i])       print(list_of_words[i], c, r)       flag = true   if flag != true:     print (list_of_words[i],0,0) 

somewhere in code (not in part have posted here) have used name str string. str string, , not built-in string type. attempting call string though function or type , python calling out on it.

to avoid problem, don't name string str.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -