#๐Ÿ”’ why am I getting parsing failed invalid syntax line 2

36 messages ยท Page 1 of 1 (latest)

covert meadow
#
from Assignment7 import passwordToHashed()
password = input("Please enter a password: ")
hashedPassword = hashedPassword(password)
myFile = open("newFile.txt","w")
myFile.write(hashedPassword + '\n')
myFile.close()
ionic topazBOT
#

@covert meadow

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

covert meadow
#

if I delete the () at the end of line 2 it gives me no name passwordToHashed in module Assignment7 eventhough there literally is

glacial oyster
#

Can you send the contents of Assignment7?

#

```py
^^^ backticks, not quotes `

covert meadow
#

assignment 7 :

import hashlib
def passwordToHashed(password):
         hashedPassword = password.encode("utf-8")
          myMD5Hash = hashlib.md5()
          myMD5Hash.update(hashedPassword)
           hashedPassword = myMD5Hash.hexdigest()
           return(hashedPassword)
glacial oyster
#

cannot reproduce the import error, have you made sure your file is saved?

covert meadow
#

I believe I just saved them both

hushed perch
#

@covert meadow your indentations are not all aligned. You need them all the same.

#

Indents only change when you place code inside something, like inside a def, an if, a while and so forth.

#

It would help to see the SyntaxError itself in all its glory.

covert meadow
#

They're not aligned because I typed them out and not copy paste into here

hushed perch
#

Right. But you need to fix this.

#

Oh. You mean they're aligned in the real code?

covert meadow
#

yes

hushed perch
#

Can you not copy/paste the real code here?

covert meadow
#

Its on my laptop

hushed perch
#

Run discord on the laptop? Just wondering.

#

Take a good photo?

covert meadow
#

I will

hushed perch
#

Ah. Drop the () from the import. You're importing a name, not calling the name.

covert meadow
#

now I get a using variable hashedPassword before assignment on line 4

#

do i move it to line 3?

glacial oyster
#

do you mean to use the function you defined in Assignment7?

hushed perch
#

Need to see it. It's obscured. And you need to say which file elicits the error.

covert meadow
hushed perch
#

hashedPassword and passwordToHased are different words.

glacial oyster
#

This assignment is probably trying to teach you how to use functions from different files yes?

covert meadow
#

I know why its messed up

covert meadow
ionic topazBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.