Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unexpected syntax error
#8
No syntax error when I run your code. Some logic and programming errors.

The argument to the function is not used anywhere
def create_password(tmp):
To call a function you need to use parenthesis. The code below does not call isupper
x = 'a'
print(x.isupper)
Output:
<built-in method isupper of str object at 0x00000179EB55C370>
In Python indentation is not just to make things look pretty. Indentation is how code blocks are defined. In the code below the for loop is not inside the while loop.
    while try_again == True:
        if length >= 8: # if password has more than 8 characters add 1 to the score 
            score = score + 1
    for x in password:
The function returns a value that is never defined.
return New_password
I think the logic could use some work too. Doesn't it feel like there are a lot of steps in calculating the score? A small change like using 1/0 instead of True/False can make a big difference:
        upper = lower = digit = special = islong = 0
        if len(pwd) > 7:
            islong = 1
        for c in pwd:
            if c.isupper():
                upper = 1
            if c.islower():
                lower = 1
            if c in digits:
                digit = 1
            if c in specials:
                special = 1
        score = upper + lower + digit + special + islong
And "in" works with strings as well as lists.
    digits = "0123456789"
    specials = "!£$%^&*()@?#"
Reply


Messages In This Thread
Unexpected syntax error - by djwilson0495 - Aug-24-2020, 10:21 AM
RE: Unexpected syntax error - by ndc85430 - Aug-24-2020, 10:26 AM
RE: Unexpected syntax error - by djwilson0495 - Aug-24-2020, 11:47 AM
RE: Unexpected syntax error - by deanhystad - Aug-24-2020, 01:27 PM
RE: Unexpected syntax error - by djwilson0495 - Aug-24-2020, 02:48 PM
RE: Unexpected syntax error - by deanhystad - Aug-24-2020, 04:18 PM
RE: Unexpected syntax error - by djwilson0495 - Aug-25-2020, 10:42 AM
RE: Unexpected syntax error - by deanhystad - Aug-25-2020, 01:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  World Clock syntax error OscarBoots 1 160 May-03-2024, 05:20 AM
Last Post: snippsat
  Syntax error for "root = Tk()" dlwaddel 15 1,288 Jan-29-2024, 12:07 AM
Last Post: dlwaddel
Photo SYNTAX ERROR Yannko 3 436 Jan-19-2024, 01:20 PM
Last Post: rob101
  Syntax error while executing the Python code in Linux DivAsh 8 1,687 Jul-19-2023, 06:27 PM
Last Post: Lahearle
  Code is returning the incorrect values. syntax error 007sonic 6 1,269 Jun-19-2023, 03:35 AM
Last Post: 007sonic
  syntax error question - string mgallotti 5 1,366 Feb-03-2023, 05:10 PM
Last Post: mgallotti
  Syntax error? I don't see it KenHorse 4 1,319 Jan-15-2023, 07:49 PM
Last Post: Gribouillis
  Syntax error tibbj001 2 940 Dec-05-2022, 06:38 PM
Last Post: deanhystad
  Python-for-Android:p4a: syntax error in main.py while compiling apk jttolleson 2 1,911 Sep-17-2022, 04:09 AM
Last Post: jttolleson
  Mysql Syntax error in pymysql ilknurg 4 2,406 May-18-2022, 06:50 AM
Last Post: ibreeden

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020