Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What Error?!
#2
Common mistake, you overlooked a parentheses, you need to close them all.
Code:
ran = str(random.randrange(0, 1000, 1)
should be:
Code:
ran = str(random.randrange(0, 1000, 1))
If you don't close them all python looks at the next line to find it which happened to contain "rep", which is why you didn't know what to fix.

Edit:
Your code still has errors I can't really see what you are trying to do so I can't fix it for you but I can tell you what your doing wrong.
Code:
ran = str(random.randrange(0, 1000, 1)
        rep = string.replace(op1, op2, ran)
        xx = rep
        aa = [xx+xx**2, xx+xx**3, xx+xx**4, xx-xx**2, xx-xx**3, xx-xx**4, xx**2+xx**3, xx**2+xx**4, xx**2-xx**3, xx**2-xx**4, xx**3+xx**4, xx**3-xx**4]

Ok so basically the "**" can't be used with strings because if you think about it a string can't be raised to a power. Logically, 'hi' to the third power means 'hi' * 'hi' * 'hi', which makes no sense, if your looking just to multiply the words, just use "*", the result will be 'hihihi'.


Edit:
Also, you can't use "-" for strings, the only way to concatenate strings is with "+" and "*".
[Image: izsyo6.jpg]


Reply


Messages In This Thread
What Error?! - by Canoris - 02-10-2010, 05:15 AM
RE: What Error?! - by uber1337 - 02-10-2010, 08:22 AM
RE: What Error?! - by Canoris - 02-10-2010, 02:52 PM
RE: What Error?! - by uber1337 - 02-10-2010, 03:09 PM
RE: What Error?! - by Canoris - 02-10-2010, 03:19 PM
RE: What Error?! - by uber1337 - 02-10-2010, 08:19 PM
RE: What Error?! - by Canoris - 02-11-2010, 05:29 AM
RE: What Error?! - by uber1337 - 02-11-2010, 08:30 AM
RE: What Error?! - by Canoris - 02-11-2010, 07:28 PM
RE: What Error?! - by uber1337 - 02-11-2010, 08:27 PM
RE: What Error?! - by Canoris - 02-12-2010, 01:46 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)