Why You No Do What I Want?

Alex likes to create a bunch of Number Theory problems. Well, here I go with my series! Please like and share (because Finn Hulse likes it when you share and like)

Alex is fairly new to computer programming, and he wants to learn Python. After 51 days of hard work and 8 days spent trying to debug (see what I did there?), he finally created a program as follows:

1
print("Hi, my name is Alex, and I'm here to deliver a speech called "OceanView". I don't know. Something like that or the other.")

But it still doesn't run! What happened? What got wrong?

For other language programmers: I don't use Python too, but since it's recommended in Brilliant for Computer Science topics to use this, I used it for this problem. print is the same as printf(), NSLog(), System.out.println(), cout <<, PRINT, etc... Semicolons aren't required. That should tell you enough (I hope)

He forgot to escape characters. He forgot a space at the end. His code is correct. Stop trying to trick me. The periods create a concatenation which screws everything up.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

11 solutions

Kevin Mo
Mar 2, 2014

The double-quotes match the one that started Oceanview. The compiler would interpret two different strings with a random unspecified variable name. The correct way would be to escape the characters by doing \".

Alex Segesta gets the problem wrong.

Alex Segesta - 7 years, 3 months ago

why python?

Spock Weakhypercharge - 7 years, 3 months ago

Log in to reply

1) Brilliant recommends all Comp Sci problems to be Python

2) Very simple, recommended for procedural novice programmers

3) I could've easily written it in C-based langauges, HTML, CSS, Javascript, Actionscript, BASIC, etc. etc., but everyone knows Python

4) Same concepts apply

@Spock Weakhypercharge

Kevin Mo - 7 years, 3 months ago

Log in to reply

No not every one knows python.. i never worked with python... but from my c++ and java exp.. i kinda figured it out

Asmit Basu - 7 years, 3 months ago

Log in to reply

@Asmit Basu Hey ...me too!!

Tanya Gupta - 7 years, 2 months ago

cool.

Spock Weakhypercharge - 7 years, 3 months ago

Why me no right? What is Python?

Robert Fritz - 7 years, 2 months ago

Log in to reply

I am assuming that it is another computer programming language like c++ or java...though I have exactly no idea...

Tanya Gupta - 7 years, 2 months ago

I got the right answer,but i mistranslate the option to my language(which end up choosing the wrong ans)-_-

Valerian Pratama - 7 years, 2 months ago

please come up with other languages too

Yashasvini Sharma - 7 years, 1 month ago
Rohit Gangadharan
Mar 27, 2014

He should have the code written this way. print("Hi, my name is Alex Segesta, and I'm here to deliver a speech called \"OceanView\". I don't know. Something like that or the other.")

Salaar Sultan
Mar 22, 2014
  1. he used print, not printf.
  2. no semicolon( ; ) at the end of statement.
  3. if he want to print "OceanView", he should use \ before each double-quotes. i.e. \".

That's a Python Code. -.-'

Prashant Sinha - 7 years, 2 months ago

I think this problem doesn't really matter which programming language you know, Its a general computer programming concepts which kinda runs through all

Daniel Anyidoho - 7 years ago
Tarun Dhiman
Mar 21, 2014

\" was forgotten in the between of the print function

Vaibhav Zambad
Mar 21, 2014

The double-quoted string i.e. "OceanView" is not a correct syntax Here it should be written as " "OceanView" " in order to print that i.e. He forgot to escape characters

Finn Hulse
Mar 15, 2014

Thanks for mentioning me! As for the problem, the computer is confused by the double quotation marks. I am honored that somebody knows me. :D

Ha ha!!!

Tanya Gupta - 7 years, 2 months ago

Thanks :D

Kevin Mo - 7 years, 2 months ago

Log in to reply

:D

Finn Hulse - 7 years, 2 months ago

The correct way would be to escape the characters by doing \"

Saddam Ranjhani
Mar 13, 2014

" inside " needs Escap Seq

He should escape the quotation marks by adding a slash before each quote like this: \"

Prakhar Agarwal
Mar 10, 2014

double quotes before oceanview will create the problem..... u have to use escape characters to redeem this problem

this is with all programming language. I firstly created this mess in PL/SQL, and then laugh like anything, thinking about goodness of unicode still to come in pl.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...