c++ to python code converter
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
struct n{
int d;
struct n*next;
};
void push(struct n**headref, int new_d)
{
struct n* new_node=new n;
new_node->d=new_d;
new_node->next=(*headref);
(*headref)=new_node;
}
float avgofnodes(struct n*head)
{
if(!head){return -1;}
int c=0;
int s=0;
float avg =0.0;
struct n*now=head;
while(now!=NULL)
{
c++;
s+=now->d;
now=now->next;
}
avg=(double)s/c;
return avg;
}
int main()
{
struct n*head=NULL;
push(&head , 7);
push(&head, 6);
push(&head, 8);
push(&head, 4);
push(&head, 1);
cout<<"Average of nodes = "<<avgofnodes(head);
return 0;
}