dimanche 28 janvier 2018

I'm trying to make a simple script that says two different two phrase lines(Python)

So, I'm just starting to program Python and I wanted to make a very simple script that will say something like "Gabe- Hello, my name is Gabe (Just an example of a sentence" + "Jerry- Hello Gabe, I'm Jerry" OR "Gabe- Goodbye, Jerry" + "Jerry- Goodbye, Gabe". Here's pretty much what I wrote.

 answers1 = [
"James-Hello, my name is James!"
]
answers2 = [
    "Jerry-Hello James, my name is Jerry!"
    ]
answers3 = [
    "Gabe-Goodbye, Samuel."
        ]
 answers4 = [
    "Samuel-Goodbye, Gabe"
    ]
Jack1 = (answers1 + answers2)
Jack2 = (answers3 + answers4)
Jacks = ([Jack1,Jack2])
import random
for x in range(2):
    a = random.randint(0,2)
    print (random.sample([Jacks, a]))

I'm quite sure it's a very simple fix, but as I have just started Python (Like, literally 2-3 days ago) I don't quite know what the problem would be. Here's my error message

Traceback (most recent call last):
File "C:/Users/Owner/Documents/Test Python 3.py", line 19, in <module>
print (random.sample([Jacks, a]))
TypeError: sample() missing 1 required positional argument: 'k'

If anyone could help me with this, I would very much appreciate it! Other than that, I shall be searching on ways that may be relevant to fixing this.




Aucun commentaire:

Enregistrer un commentaire