Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Python noob and numbers
11-03-2013, 01:19 PM #1
- Join Date
- Sep 2010
- Thanked 0 Times in 0 Posts
Python noob and numbers
Have only just started learning Python and to practice what i have learned so far i wrote this:
#!/usr/bin/python i = 'Skype' j = 46,178,617 x = 'VOIP' Z = "Making it a market leader in it's field." print "%s is an online %s product." % (i, x) print "It has over %d million regular user's daily." % j print "Making %s a market leader in it's field." % i
Skype is an online VOIP product.
Traceback (most recent call last):
File "./more_practice.py", line 8, in <module>
print "It has over %d million regular user's daily." % j
TypeError: not all arguments converted during string formatting
I am convinced that the problem is down to the variable, j = 46,178,617 because it is such a large number. So could someone tell me how i can display the contents of the variable correctly please.
05-05-2014, 04:01 AM #2
- Join Date
- Mar 2009
- Thanked 2 Times in 2 Posts
Hello Frump, You are correct, the issue is with that variable j.
The simplest way to resolve this is to make it a string. You can do so by changing the value to
j = "46,178,617"
print "It has over %s million regular user's daily." % j
j = (46, 178, 617)The Game