How to Pass Structure Variables in Python


This example tells how to pass the structure variables in Python.

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

class person:
    age = 0
    name = 0
def f(people):
    people.age = 20
    people.name = 'George'

a = person()
a.year = 35
a.name = 'Jack'
f(a)

print('The age of the person: %s'%a.year)
print('The name of the person: %s'%a.name)

Output:

The age of the person: 35
The name of the person: George
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments