I don't know why it's giving a SyntaxError

So, I was doing this Edabit python challenge: https://edabit.com/challenge/EWZqYT4QGMYotfQTu

And this is my code:

tap_dict = {
    "a": ". .", "b": ". ..", "c": ". ...", "d": ". ....", "e": ". .....", "f": ".. .", "g": ".. ..", "h": ".. ...", "i": ".. ....", "j": ".. .....", "k": ". ...",
    "l": "... .", "m": "... ..", "n": "... ...", "o": "... ....", "p": "... .....", "q": ".... .", "r": ".... ..", "s": ".... ...", "t": ".... ....",
    "u": ".... .....", "v": "..... .", "w": "..... ..", "x": "..... ...", "y": "..... ....", "z": "..... ....."
}

def tap_code(text):
    def tap_to_code(text):
        k = text.split()
        # print(k)
        
        tap1 = k[0::2]
        tap2 = k[1::2]
        # print(tap1, tap2)
        
        taps = list(zip(tap1, tap2))
        # print(taps)
        
        new_taps = []
        for couple in taps:
            new_taps.append(" ".join(couple)
        
        print(new_taps)
    
    def code_to_tap(text):
        pass
    
    if len(text.split()) > 1:
        tap_to_code(text)
    
    elif len(text.split()) == 1:
        code_to_tap(text)

tap_code(".... .... ... .... ... ... .. .... .. .. .. ... .... ....") #tonight

Why is this giving me a SyntaxError?
image

Rule of thumb here for me is:

If the error points at something that is valid, the error must be very near the code before it.

1 Like

Oh, thanks, you actually helped me :slight_smile:
Right here:

new_taps.append(" ".join(couple) # it was missing the second ")"
1 Like

That was the plan :wink:

1 Like

my input-

print(“The GE train supplies " + str(train_force) + " Newtons of force.”)

OUT put

File “script.py”, line 18
print(“The GE train supplies " + str(train_force) + " Newtons of force.”)
^
SyntaxError: invalid character in identifier

Question -

can some one please explain why I am getting this error? it seems right to me, and similar thing was done on the video by the instructor for this project

please provide some thought that will help, as I can not precede on this.

Can you post the rest of your code- and don’t forget to check before it for any errors, like @toastedpitabread said.

1 Like

It may sound weird, but, when I get an error, I read the code from the bottom up to the top. It’s just a different way of looking at it and I’m able to see the syntax issue or whatever it is.

3 Likes

train_mass = 22680

train_acceleration = 10

train_distance = 100

bomb_mass = 1

def f_to_c(f_temp):

return f_temp - 32 * 5 / 9

f100_in_celsius = f_to_c(100)

def c_to_f(c_temp):

return c_temp * (9 / 5) + 32

c0_in_fahrenheit = c_to_f(0)

def get_force(mass, acceleration):

return mass * acceleration

train_force = get_force(train_mass, train_acceleration)

print(train_force)

print(“The GE train supplies " + str(train_force) + " Newtons of force.”)

Hi there. Were you able to find the issue?
If you could please format your code by selecting the “preformatted text button” at the top that would be helpful.

Indentation matters in Python when writing code b/c it tells the compiler what blocks of code belong together and when/what order to execute them.
https://www.geeksforgeeks.org/indentation-in-python/

You left out a couple spaces in your print statement pasted above :arrow_up:

Also, concerning your error, check out this resource:
https://stackoverflow.com/questions/14844687/invalid-character-in-identifier#14844830

Double check your functions too. There’s a little bit of confusion in the first function. The question asks you to return “c_temp” after defining what it is: “Temp © = (Temp (F) - 32) * 5/9”

thanks, let me see if I can figure this out