8. Keeping Track of the Produce question

  1. Keeping Track of the Produce

I am wondering if there is a difference between these two methods

  • ps:I know how to fix the activity just wondering if my method is the wrong way of doing things.

I learned to create custom text by doing something along the line of:

name=input("Enter your name")
print ("Hello: ",name)

so as a result I did this:

prices = {
stock = {

for z in prices:
  print z
  print 'price: ',prices[z]
  print 'stock: ',stock[z]

just wondering why python ask u to do it like (below)
is this method better, or just another way of doing the same thing?

once  = {'a': 1, 'b': 2}
twice = {'a': 2, 'b': 4}
for key in once:
  print "Once: %s" % once[key]
  print "Twice: %s" % twice[key]

picture to easier visualize-


Hi @paulaswam,

Codecademy does not want the user to include a print statement that inserts a blank line in the output.



please read my entire question


The lesson expects a string printing value. so you need to use string formatting syntax ( %s ) here.

that’s the difference.


Codecademy wants you to use their example as a model, so that you can practice string formatting. That is not meant to imply that it is always the best way to do it.


@appylpye thanks for your insight

To be honest I don’t understand what u mean by ‘string formatting syntax’. because from what I see they produce the same output. can you explain?


sure :slight_smile:

look at here

print 'hello',1
print 'hello %s'%1
print '...................'

if you run the above code the output will be the same.but both are not same type.

s='hello %s'%1
print t==s
print '....................'
print t
print s
print '....................'
print type(t)
print type(s)

The first one is tuple and second one is string.

producing same output is always not same.

print 5 # type int
print '5' # type str


thank you, I understand what you mean now. :smiley:


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