Printing variables with %r

What if we put the string inside another string?

1
2
3
4
5
6
os = "Android"
device = "mobile"

fact = "%s is the most-installed %s operating system in the world." % (os, device)

print "As of 2011: %r" % fact

As of 2011: 'Android is the most-installed mobile operating system in the world.' As of 2011: "Android is the most-installed mobile operating system in the world." As of 2011: Android is the most-installed mobile operating system in the world. TypeError: 'str' object is not callable

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

0 solutions

No explanations have been posted yet. Check back later!

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...