-3

Essentially I have run into a problem regarding a Type Error on line 3, I am presented with "TypeError: 'str' object is not callable" Any advice would be appreciated /Ubuntu/python3/terminal

import os
#Imports operating system modules
user_file_search = input()('Type Millienium2000')
#Prompt the user to enter password
encoded = user_file_search.encode('hex')
#Decodes files based on hex

for root, dirs, files in os.walk ('/Desktop/POP/PoP_Coursework_Assignment/Svr1/documents$'):
    for data in files :
        pass_file = open(os.path.join(root,data)).read()

if(encoded in pass_file):
    print ('This could be the pass : {}'.format(os.path.join(root,data)))
    print ('Located data: {}'.format(pass_file))
#Prints Data retrived

I am presented with the following

Traceback (most recent call last):

File "oswalk.py", line 3, in

user_file_search = input()('Type Millienium2000')

TypeError: 'str' object is not callable

Thanks in advance!

UPDATE! Code is working fantastically now! Thanks all! I have encountered a new issue being told that

File "oswalk.py", line 5, in

encoded = user_file_search.encode('hex') LookupError: 'hex' is not a text encoding; use codecs.encode() to handle arbitrary codecs

All the files Im searching through are encoded with HEX, is it because there's an alternative input for hex?

4
  • 2
    Remove the empty parentheses!
    – Klaus D.
    Aug 2, 2018 at 16:32
  • 1
    input('Type Millienium2000'). Closing as typo. Aug 2, 2018 at 16:33
  • Are you trying to print that statement before the input? If so you put the string inside the input call: input('Type Millienium2000'). You can't add extra parentheses and call it that way
    – Dan
    Aug 2, 2018 at 16:34
  • Ahh thank you so much, its funny how hard it is coming back to coding after a break! , That solved my problem. Aug 2, 2018 at 16:49

2 Answers 2

0

You have to put string into parentheses.

Like this:

import os
#Imports operating system modules
user_file_search = input('Type Millienium2000')
#Prompt the user to enter password
encoded = user_file_search.encode('hex')
#Decodes files based on hex

for root, dirs, files in os.walk ('/Desktop/POP/PoP_Coursework_Assignment/Svr1/documents$'):
    for data in files :
        pass_file = open(os.path.join(root,data)).read()

if(encoded in pass_file):
    print ('This could be the pass : {}'.format(os.path.join(root,data)))
    print ('Located data: {}'.format(pass_file))
#Prints Data retrived
1
  • Spot on! Thank you ! Aug 2, 2018 at 16:52
0

This is correct behavior input() returns a string and I do not know why you are trying to call something of it:

input()('Type Millienium2000') translates to "SOMETEXT"('Type Millienium2000')

If you would like to prompt user for data it should be like this:

input('Type Millienium2000:')

1
  • "Conveniently, the person who has hidden this password cannot resist the temptation of leaving their signature. The signature is the text string “Millenium2000”" Basically I need to find the file with the same signature while making the program automated. Aug 2, 2018 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.