+ 1

print(Spam*3)... Whether quotes is compulsory here?🔝

12th Jan 2017, 2:42 PM
seetha
seetha - avatar
12 Answers
+ 12
Unless you declared Spam perviously, it won't work with that line by its self(like sun said). You'll get a declaration error saying Spam is undefined.
12th Jan 2017, 2:59 PM
Brandon Baldwin
Brandon Baldwin - avatar
+ 6
Spam have to be variable . if not you need quotes
12th Jan 2017, 2:47 PM
Sun
Sun - avatar
+ 1
I run it on my trusty bpython3 and its not running without quotes
12th Jan 2017, 2:51 PM
Sun
Sun - avatar
+ 1
its not running , are u using sololearn compiler ?
12th Jan 2017, 2:55 PM
Sun
Sun - avatar
+ 1
yeah.. sololearn python
12th Jan 2017, 2:56 PM
seetha
seetha - avatar
+ 1
its not working in my sololearn compiler as well as main python3 on pc
12th Jan 2017, 2:57 PM
Sun
Sun - avatar
+ 1
yeah. its my mistake only.. i dint notice that they gave some value for spam in the beginning...
12th Jan 2017, 2:59 PM
seetha
seetha - avatar
+ 1
now i understood.. thanks.. for ur explanation
12th Jan 2017, 2:59 PM
seetha
seetha - avatar
+ 1
because spam="eggs"
12th Jan 2017, 4:43 PM
rasoul norouzi
rasoul norouzi - avatar
0
spam. is a string so obviously a string needs qoutes right.. but without quotes its working.. i cant understand why
12th Jan 2017, 2:49 PM
seetha
seetha - avatar
0
but for me its running...bro u gave print before that
12th Jan 2017, 2:52 PM
seetha
seetha - avatar
0
spam='hi' print(spam*3) in here spam is already a string so that is why it will print hihihi ---------- spam='hi' print ('spam'*3) this will print spamspamspam
12th Jan 2017, 11:50 PM
ramzi
ramzi - avatar