Jump to content

Python 3 Beginner question

Go to solution Solved by Electronics Wizardy,

Look at line 29, you probalby want a + not a Equals sign there

So I have started taking Python 3 courses and it's my first programming language. I am trying to make a funny magic 8-ball program, but something isn't adding up and I keep getting an "invalid keyword argument" error while executing.

I am certain it's probably something silly and simple, but it's still evading me.

 

Also, this is my first day learning.

 

image.thumb.png.f49781a1afd165c1e0f24d830aa01b2f.png

 

I appreciate any help and tips!

Link to comment
Share on other sites

Link to post
Share on other sites

1 minute ago, Electronics Wizardy said:

Look at line 29, you probalby want a + not a Equals sign there

🤦‍♂️

Link to comment
Share on other sites

Link to post
Share on other sites

7 minutes ago, CubisticWings4 said:

Thanks. lol

was gonna say bout that, been learning the language for 2 years

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, ComputerBuilder said:

was gonna say bout that, been learning the language for 2 years

I mean, I knew something was off but it never clicked that it was trying to define name twice. 

Link to comment
Share on other sites

Link to post
Share on other sites

in-these situations, where you are writing lots of ifs i like to refactor into something like this

 

from random import randint

answers = [
  'well yes, but actually no',
  'Nah, you bitch',
  'not sure. Still a bitch tho.'
]

random_number = randint(0,len(answers)-1)
answer = answers[random_number]

print(answer)

 

 

I find it much easier to follow and allows you to add more answers by simply appending to an array, also will let you load then answers from a text file

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×