Codeacademy supermarker


#1

<PLEASE USE THE FOLLOWING TEMPLATE TO HELP YOU CREATE A GREAT POST!>

<Below this line, add a link to the EXACT exercise that you are stuck at.>
https://www.codecademy.com/courses/learn-python/lessons/a-day-at-the-supermarket/exercises/keeping-track-of-the-produce-?action=lesson_resume&link_content_target=interstitial_lesson

<In what way does your code behave incorrectly? Include ALL error messages.>
Why it is %s and not %d ?

<What do you expect to happen instead?>

```python

Replace this line with your code.
prices = {“banana”: 4,
“apple”: 2,
“orange”: 1.5,
“pear”: 3}

stock = {“banana”: 6,
“apple”: 0,
“orange”: 32,
“pear”: 15}

for fuds in prices:
print fuds
print “price: %s” %(prices[fuds])
print “stock: %s” %(stock[fuds])

<do not remove the three backticks above>

#2

Hi @dsoph,

Try using %d as an experiment, and observe the effect it has on how the price for orange is displayed.

The %s specifier renders a value in its default string representation. The author of this course decided that users should use that default representation for the output. However, for your own programs, you can make another design choice if you feel it is best for the specific situation.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.