+ 2

How to access a variable from another class

Hello so basically i need to access a variable called 'forwdd' from function 'move_forward' from class Turtle to new function 'print_distance' in new class called 'TurtleGTX'. And i have attached my try. Please help🙏 https://code.sololearn.com/c6YC3wv49Tyj/?ref=app

22nd Aug 2020, 8:45 AM
Karan
Karan - avatar
2 Réponses
+ 3
define it as instance variable in init with value 0 and change it in the function. Thats all😉
22nd Aug 2020, 8:51 AM
Oma Falk
Oma Falk - avatar
0
Ty Oma Falk it works
22nd Aug 2020, 8:57 AM
Karan
Karan - avatar