Skip to content
← Back to Community
I am getting an error and I want a fix .-.
Profile icon
MATTHEWBECHTEL

Here is the link - https://repl.it/@MATTHEWBECHTEL/Ffncehjanddfkicysbjizdpch3pco
It says SyntaxError: EOL while scanning string literal
As stated in the screenshot below
33007BF8-8032-4BC3-A40D-610F265A9578

Answered by JustARatherRidi [earned 5 cycles]
View Answer
Voters
Profile icon
MohammadAdnan3
Profile icon
MATTHEWBECHTEL
Comments
hotnewtop
Profile icon
JustARatherRidi

That's odd, the repl works fine for me. However, from the picture, your ending double quote looks a bit odd. Are you typing on your mobile?

Profile icon
MATTHEWBECHTEL

I fixed before you typed your message if you scroll through the messages but I have a new problem now .-. The repl won’t even run now. @JustARatherRidi

Profile icon
JustARatherRidi

@MATTHEWBECHTEL Did you fix this one as well? because this one seems fine too.

Profile icon
heyitsmarcus

@MATTHEWBECHTEL What I can't fathom is why you would accept the answer that does nothing towards helping you find a solution.

And the way you wrote the functions is a bad programming habit you'll want to get out of right away. Don't overwrite a function over and over again with different behavior to accommodate new functionality; instead, implement different behavior into your original function to accommodate new functionality.

Profile icon
MATTHEWBECHTEL

It’s fine. @JustARatherRidi

Profile icon
MATTHEWBECHTEL
Profile icon
JustARatherRidi

@MATTHEWBECHTEL I agree with @heyitsmarcus here, you definitely should have chosen his answer.

Profile icon
MATTHEWBECHTEL

Can’t change the past. @JustARatherRidi

Profile icon
JustARatherRidi

@MATTHEWBECHTEL You're right, but you should try and choose the answer that is more relevant to you and others in the future.

Profile icon
MATTHEWBECHTEL

Isn’t there a song about that or something. @JustARatherRidi

Profile icon
MATTHEWBECHTEL

Also you forgot the period at the end of your sentence. @JustARatherRidi

Profile icon
JustARatherRidi

@MATTHEWBECHTEL Idk, if there is it doesn't seem like my kind of song, not gonna lie. What period?

Profile icon
MATTHEWBECHTEL
Profile icon
heyitsmarcus

If you're going to have two different time.sleep() times, you should just pass in the time to the original write function that you need like so:

import sys, time def write(string, fltime): for char in string: sys.stdout.write(char) sys.stdout.flush() time.sleep(fltime) write("I am going to count to 1 to 1,000. ", 0.025) time.sleep(0.75) write("Follow every word and diget to know if this speed is just right for you. ", 0.025) time.sleep(0.75) write("Here we go. ", 0.025) time.sleep(.5) write("10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100. ", 0.015)

Here's a fork of your repl: https://repl.it/@heyitsmarcus/Writing-as-though-typing

If this solves your problem, please upvote and select my answer as the accepted answer to close this question.

Profile icon
MATTHEWBECHTEL

Maybe I’ll that try that thanks. Btw I like knives more than forks. Spoons are good aswell. @heyitsmarcus

Profile icon
heyitsmarcus

@MATTHEWBECHTEL Well, I can tell I wasted my time attempting to help you. Good luck, bud. You're going to need it.

Profile icon
MATTHEWBECHTEL

......... I don’t get what the number at the end of the sentence does. @heyitsmarcus

Profile icon
MATTHEWBECHTEL

They don’t even do anything.... @heyitsmarcus

Profile icon
heyitsmarcus

@MATTHEWBECHTEL If you look at your original write function, there is a second parameter that I named fltime (you could rename this to something else). In the very bottom line of the function, where you have time.sleep(0.03), I changed it to time.sleep(fltime) which will allow the function to use whatever value you pass in.

That means that you can control the time in every single write statement without having to overwrite the write function multiple times. You will only have one write function instead of tons of them, which you should not have...

Profile icon
MATTHEWBECHTEL

Yeah but what does the numbers at the end of every write function mean? @heyitsmarcus

Profile icon
heyitsmarcus

@heyitsmarcus Notice that I passed in the time to sleep at the end of every write call. This means you have more power over the program, it's more efficient, and other people will know what's going on.

Profile icon
MATTHEWBECHTEL

Ok so basically what I notice is going on is that in line 7.... between every write command it waits that amount so I’m very confused why we have the numbers at the end of the write statements separated by commas. I am re-writing the write statement because I want pauses like a human would talk. @heyitsmarcus

Profile icon
heyitsmarcus

@MATTHEWBECHTEL The comma separates parameters given to functions and the parameters themselves. In your first function, you had only one parameter, so there are no commas needed to separate any other parameters.

i.e.

def write(string): ... #and then in every function call... #only one parameter, which is string write("I am bob the robot.")

But, when you add more parameters, you separate them by commas inside the function. The way you are writing it, you have to overwrite the function every single time you want to change the timing. What I showed you is a way to not do that. It's the way that everyone else is going to use because not only is it more efficient but it's more readable.

#two parameters, separate them by commas def write(string, fltime): ... #and then in every function call... #there are two parameters #first one is the string to use #second one is the timing to use for this write statement write("I am bob the robot.", 0.03)

Does that make sense? Also, please upvote these comments because I'm spending a lot of time helping you lol.

Profile icon
MATTHEWBECHTEL

Sure I’ll upvote every comment you use to help me XD. Ok let me say this back to you... do it my way cuz it’s better, more efficient, and better. I’m not disagreeing. and.... the first one is for how much time it waits between characters, and the number at the end of the scent since I’d the time it waits between every time of “write” statements. @heyitsmarcus and you have 74 upvotes now. Good job.

Profile icon
heyitsmarcus

@MATTHEWBECHTEL Matthew, this is not my way. This is the way that programmers do it. I wasn't the inventor of doing things in that way. It's a way that not only makes more sense, but is again, more readable to other programmers who are trying to flipping help you.

You have a poor attitude, Matthew, and again, best of luck bud.

Profile icon
MATTHEWBECHTEL

Yeah, I know that lol. But did I at least understand the code right? @heyitsmarcus

Profile icon
heyitsmarcus

@MATTHEWBECHTEL Okay, I'll try this again, but please refrain from sarcastic comments lol.

Look at the last line of your write function. That number you have in there is a constant. But you can make it into a variable, so that you can pass it in to your write function like I showed you in the forked code. The number that I pass in each time to write takes the place of fltime in the function. Does that make more sense?

Profile icon
MATTHEWBECHTEL

Yes it does, and I actually wasn’t being sarcastic at all before though. @heyitsmarcus

Profile icon
heyitsmarcus

@MATTHEWBECHTEL Now not to confuse you any further, but instead of having to remember those times, you can write in your own constants. Like let's say one time is slower than another, you could store 0.03 as slowType and 0.015 as slowerType. And instead of remembering and passing back those numbers, you just pass back slowType and slowerType like this:

import sys, time slowType = float(0.03) slowerType = float(0.015) def write(string, fltime): for char in string: sys.stdout.write(char) sys.stdout.flush() time.sleep(fltime) write("I am going to count to 1 to 1,000. ", slowType) time.sleep(0.75) write("Follow every word and diget to know if this speed is just right for you. ", slowType) time.sleep(0.75) write("Here we go. ", slowType) time.sleep(.5) write("10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100. ", slowerType)
Profile icon
MATTHEWBECHTEL

@heyitsmarcus Ok, I'll try it when I get time. (:

Profile icon
heyitsmarcus

Your repl is running fine. Did you already fix the problem?

Profile icon
MATTHEWBECHTEL

Yeah but there’s a new problem now XD. @heyitsmarcus

Profile icon
MATTHEWBECHTEL

Wait never mind... I fixed it. The error was in line 8 and 10. The last 2 " was “ instead. Sorry.

Profile icon
MATTHEWBECHTEL

Please someone.