Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help with coding syntax
#1
Bug 
i am getting an invalid syntax on my python code am a newbie and i dont know what to do. can someone please help me restructure the code

#coding = utf8
import sys 
from telethon import moneygramClient 
import time 
import datetime 
starttime + time.time () 
 
#Use Details from mygram.org
api_id =  
api_hash = '' 
groups =[''] 
 
#groups = ['payfield']
  
failcount = 0;

 
#The first parameter is the .session name (absolute paths allowed)
while True:											with moneygramClient('anon', api_id, api_hash) as client:

for x in
       groups:
try:

client.loop.run_until_complete (client.
							  send_message
							  (x, 'test 

message'))
   

except:
print (x, sys.exc_info ()[0]) 
 failcount +=
    1 
 print (datetime.datetime.now (),
	       
str (failcount / len (groups) * 100) +
	       '%') 
 time.sleep (10800 - ((time.time - starttime) % 10800))
Reply
#2
I added some comments, things are undefined, unassigned and indented incorrectly and split onto separate lines when they shouldn't be.
import sys 
from telethon import moneygramClient 
import time 
import datetime 
starttime + time.time () # starttime not defined
  
#Use Details from mygram.org
api_id =  # nothing has been asigned
api_hash = '' 
groups =[''] 
  
#groups = ['payfield']
   
failcount = 0; # ; not required
 
  
#The first parameter is the .session name (absolute paths allowed)
while True:                                         with moneygramClient('anon', api_id, api_hash) as client: # this should not be on the same line as the while true
 
for x in # indentation is wrong
       groups: # this should be on the end of the previous line
try: # all indenting from here on is wrong
 
client.loop.run_until_complete (client. # this should be indented into the try and the following lines up and including message line should all be on one line
                              send_message
                              (x, 'test 
 
message'))
    
 
except:
print (x, sys.exc_info ()[0]) 
 failcount +=
    1 
 print (datetime.datetime.now (),
            
str (failcount / len (groups) * 100) +
           '%') 
 time.sleep (10800 - ((time.time - starttime) % 10800))
Reply
#3
i removed the identifiers can you pls help me edit and repost the right indentation. i am having trouble with indentation.
Reply
#4
you probably want the following line to assign to starttime
starttime + time.time ()
Is it formatted correctly where you have copied it from?
Reply
#5
yes..
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020