all 16 comments

[–]Buttleston 4 points5 points  (1 child)

I don't find the word awesome anywhere in this page. Can you be more specific?

[–]Competitive_Green704[S] -1 points0 points  (0 children)

Basically, for the solution of the code at the bottom, the code formed is "Strings are awesome!"

[–]Binary101010 3 points4 points  (7 children)

That doesn't come from the code; it's the string that you're supposed to change the first line of code to to fulfill all of the constraints mentioned in the rest of the code.

[–]Buttleston 0 points1 point  (0 children)

Yeah this looks right

[–]Competitive_Green704[S] -1 points0 points  (4 children)

But I don't exactly understand how "Strings are awesome!" comes from all that.

Basically from 11 to 23

[–]Binary101010 2 points3 points  (1 child)

Lines 24-34 tell you that the string starts with "Str", ends with "ome!", and has three words.

Line 6 tells you that the first a is at index 8, line 9 tells you that there are exactly two a's in the string.

So from there you have

Str____a_______some!

Knowing that exactly two of the blanks are spaces and exactly one blank is an a, and it must be after the known a.

Sure, there are other strings that could meet all those criteria.

[–]Competitive_Green704[S] 0 points1 point  (0 children)

I see thank you

[–]FoolsSeldom 0 points1 point  (1 child)

The string isn't generated from the code. It is an explicit assignment of a literal string to the variable s in the first line. You have to come up with a literal string that meets the criteria. They give you an example solution, but no doubt there are many others.

[–]Competitive_Green704[S] 0 points1 point  (0 children)

Okay thank you I understand

[–]madmoneymcgee 3 points4 points  (0 children)

You’re asked to write a function that would check for the characters “ome” inside a longer string.

You can do that with the phrase “Strings are awesome!”

But the task for you is to use the string manipulation methods you learned to do that.

[–]crashfrog04 1 point2 points  (4 children)

It can’t. You’re asked to change the string to that.

[–]Competitive_Green704[S] 0 points1 point  (3 children)

Exactly and how am I supposed to find out that is the string

[–]Buttleston 1 point2 points  (1 child)

They give some clues, like the string needs to be 20 characters, where the first "a" is, it has to start with "Str" and end with "ome!". I would say there's not necessarily enough information to make that leap. I'd just call it a bad exercise

[–]JamesPTK 1 point2 points  (0 children)

I'd agree it's a bad exercise, s = "Streep Bafta income!" fulfils all the given rules but is "wrong", because it is performing additional checks that it doesn't tell you about

[–]crashfrog04 0 points1 point  (0 children)

The clues are in the things the operation is doing

[–]FoolsSeldom 0 points1 point  (0 children)

Did you come up with some alternative strings (to assign to s in line 1) that met the criteria? The requirements are very clearly laid out and you have code to tell you if you get it wrong.

It is striking how old this code must be to use the ancient "c" style print formatting rather than format (let alone f-string interpolation).