I am a novice and I'm trying to create a program that returns a random syllogism. This list contains four modules which I created. Each of these modules are themselves a program that returns a random item using random.choice(). I want the program to return just one type of syllogism, but it keeps returning all 4. I've tried, random.randint(), random.sample(). I've tried using a tuple, putting the variables in quotes, importing individual modules as wildcards, putting the variables outside the function. All with the same result. The script below is using an init.py file.
This is the output that I get when I run the program.
Brittany's night turns bossy when it is youthful
It is youthful
Brittany's night has become bossy
Supposing that Margaret's air gets buzzing when it is whole
And if it is whole
At that point Margaret's air is buzzing
Either it's cheap or else Basil's delivery has become naughty
It isn't cheap
Basil's delivery has become naughty
All competition are sale
All clerk are competition
All clerk are sale
<function Syll3 at 0x7f1436379a60> # this line only appears if I use print instead of return.
This is the problem code:
import random
import multi_syllogisms
def main():
a = multi_syllogisms.Syll1
b = multi_syllogisms.Syll2
c = multi_syllogisms.Syll3
d = multi_syllogisms.Syll4
x = [a, b, c, d]
return random.choice(x)
main()
Aucun commentaire:
Enregistrer un commentaire