The task describes the pattern as: id productName price quantity. So how I picture it is this (for example): 1 iPhone 2xs 1999.99 3. So if the name (iPhone 2xs) has spaces and numbers in it, how can I distinguish betwen what is what, I mean where the name finishes and the ''price'' starts?
How does the pattern look like?
Resolved
Comments (3)
- Popular
- New
- Old
You must be signed in to leave a comment
Guadalupe Gagnon
12 March 2020, 00:46solution
You dont need to worry about it in this task because all the products are on their own line. Read each line and output the one that starts with the correct id.
In other tasks they will specify how many chars each item has. So for example id could be the first 6 chars, product the next 20, price would be 8, and quant would be 4 (padded with spaces). So the product string for that would look like this:
"1 iPhone 2xs 1999.99 3 "
+2
Guadalupe Gagnon
12 March 2020, 00:53
It does look like in this task the file data each line has the product details split only by space. So it would be:
"1 iPhone2xs 1999.99 3"
Be careful how you search for the id. If your test id is "123" and you search for that using the the wrong methods, it could hit for numbers like "1234" or "5123".
0
catalinene
12 March 2020, 11:49
Thanks a lot! Just passed it!
+1