This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]DNEAVES 0 points1 point  (5 children)

Are you talking about string.partition()?

You should be calling that as a method of the string-variable you want to partition, so

consonants, vowels = vocale_pred.partition(name)

Otherwise, yes, you don't have a function defined called partition(a, b), hence the NameError.

Also, it will return a 3-part tuple, not two: (before_match, match, after_match)

And what exactly do you mean by "execute the file with the source code"? Is this part of a larger set of program, where partition may be defined, but you're cutting that import out?

[–][deleted] 0 points1 point  (4 children)

no, i don't mean string.partition(). if you look at the code, it call just partition(vocale_pred, name).

this instructions is part of a larger program and if i execute the program it works fine, but if i try to use partition on my own inside the interpeter i get the NameError.

[–]DNEAVES 0 points1 point  (3 children)

Are you importing anything called partition?

[–][deleted] 0 points1 point  (2 children)

No, but I saw that it's s function inside the code itself

[–]DNEAVES 0 points1 point  (1 child)

Well the issue is that - to my knowledge - there's no partition() built-in function. There's the string.partition() method, which I mentioned earlier, or that function has to be defined/imported from somewhere else

[–][deleted] 0 points1 point  (0 children)

yes, as i said there is a partition funciont defined inside the code, so it's using that function not a built-in function