python 3.8.1 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

python 3.8.1

Hey! I don't know why this code doesn't run with python3.8.1, i thought the codes were the same in python3. help please ! :( This is the code with the mistakes Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019, 23:11:46) [MSC v.1916 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class Animal: ... def __init__(self, name, color): ... self.name = name ... self.color = color ... >>> class Cat(Animal) File "<stdin>", line 1 class Cat(Animal) ^ SyntaxError: invalid syntax >>> def purr(self) File "<stdin>", line 1 def purr(self) ^ IndentationError: unexpected indent >>> print("Purr...") File "<stdin>", line 1 print("Purr...") ^ IndentationError: unexpected indent >>> >>> class Dog(Animal): ... def bark(self): ... print("Woof!") ... >>> fido = Dog("Fido", "brown") >>> print(fido.color) brown >>> fido.bark()

20th Mar 2020, 2:42 AM
Karen Rubi Gutierrez Romero
Karen Rubi Gutierrez Romero - avatar
7 Answers
+ 6
Edit your post and add the code you're talking about, and don't forget to add the error code as well.
20th Mar 2020, 2:43 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 4
Karen Rubi Gutierrez Romero this is not a script. Python interpreter is not meant to write serious code, it is meant to write very small actions or to test something, and problems such as the ones you're facing are to be expected. You are writing entire classes in the python interpreter, which will only lead to more problems, and will almost be impossible to fix and debug. Write your code in a single file, and run it. If you still get errors, then we'll be happy to help you fix the problem. Good luck 👍
21st Mar 2020, 12:35 AM
Aymane Boukrouh
Aymane Boukrouh - avatar
+ 3
I dont think Python 3.8.x has been released here yet... or is it?
21st Mar 2020, 12:32 AM
Name Omitted until I come back
+ 1
"helo" Wait did he logged the error in logging or its just me?
21st Mar 2020, 12:36 AM
Name Omitted until I come back
0
Definitions of cat and purr don't have any ':' in your text, dognbark defs do, that's one difference.
21st Mar 2020, 8:00 AM
loeckchen[INACTIVE]
0
Ipython is imho too simplistic for class stuff, why not use a practical IDE or simple texteditor?
21st Mar 2020, 8:07 AM
loeckchen[INACTIVE]
0
Thanks guys! I will check it (:
21st Mar 2020, 2:17 PM
Karen Rubi Gutierrez Romero
Karen Rubi Gutierrez Romero - avatar