geekcomputers / geekcomputers/Python

New to python had a problem

Open
#476 10 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
35.4k
Forks
12.9k
Avg merge
2h 37m
Merged PRs (30d)
1

Description

hello,everyone I was having time to learn python so i started learning it from day before yesterday,now I am trying to make snake game from curses module and I ran into A TROUBLE, figured someone from here would lend me some of their experience regarding this
the document is the photograph of the code fragment
Document 8.pdf

class Snake(object):
def init(self):
self.x='Hiss!'
def method_a(self,foo):
print(self.x +' '+ foo)

snake = Snake()
snake.method_a('Says the snake')

the above code fragment is having an error
upon trying to run it the terminal gives the following

Traceback (most recent call last):
File "hc.py", line 31, in
snake.method_a('Says the snake')
File "hc.py", line 28, in method_a
print(self.x +' '+ foo)
AttributeError: 'Snake' object has no attribute 'x'

can't find where the error is so i request you guys to please help me if you know any thing regarding this

and sorry i forgot the most important part of info iam using python 3.7.2 64 bit on windows 7

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Snake class and traceback in the issue body, then inspect the linked Document 8.pdf for the original code fragment. Reproduce the example with Python 3.7.2 and confirm that initialization creates the attribute used by method_a without producing the reported AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.