• Instructions to Ask a Question

    Click on the "Ask a Question" button and select the application for which you would like to ask questions.

    We have 5 different products namely - Pabbly Connect, Pabbly Subscription Billing, Pabbly Email Marketing, Pabbly Form Builder, Pabbly Email Verification.

    The turnaround time is 24 hrs (Business Hours - 10.00 AM to 6.00 PM IST, Except Saturday and Sunday). So your kind patience will be highly appreciated!

    🚀🚀Exclusive Discount Offer

    Just in case you're looking for any ongoing offers on Pabbly, you can check the one-time offers listed below. You just need to pay once and use the application forever -
     

    🔥 Pabbly Connect One Time Plan for $249 (🏆Lifetime Access) -  View offer 

    🔥 Pabbly Subscription Billing One Time Plan for $249 (🏆Lifetime Access) - View offer

Issue with Python Code

Status
Not open for further replies.

inochi

Member
Your Task History ID
IjU3NmQwNTZlMDYzNzA0MzQ1MjZiNTUzNCI_3D_pc
Hello,

after updating Python & Javascript Code, I can no longer get the codes I had before to work.

I give an example just to understand:

import datetime import random now = datetime.datetime.now() # ottieni l'orario corrente in Italia delta = datetime.timedelta(minutes=random.randint(10, 60)) # genera un intervallo casuale tra 10 e 60 minuti random_time = now - delta # sottrai l'intervallo casuale all'orario corrente per ottenere un orario casuale precedente time_diff = now - random_time hours_diff = time_diff.seconds // 3600 minutes_diff = (time_diff.seconds // 60) % 60 if hours_diff == 0: time_ago = f"{minutes_diff} minuti fa" elif hours_diff == 1: time_ago = f"1 ora e {minutes_diff} minuti fa" else: time_ago = f"{hours_diff} ore e {minutes_diff} minuti fa" output = [{"random_time": time_ago}] print(output)
I would use this code to randomly generate the hours and minutes and then the output would return with the random numbers. Example: 1 hour and 30 minutes ago.

After updating, most of the code gives me an error.
In this particular case, with this code I posted, I get the error:

"name 'random_time' is not defined"

How can I solve it?

Thank you
 

Attachments

  • Screenshot del 03-01-2024 alle 17.16@2x.png
    Screenshot del 03-01-2024 alle [email protected]
    38 KB · Views: 41

ArshilAhmad

Moderator
Staff member
Hi @inochi,

Please record a short screen recording running this code in an online compiler. Additionally, run the same code in Code by Pabbly and show the responses you get in both scenarios.
 

inochi

Member
Of course.
The problem is only on Pabbly Connect.

Here's the result on an online compiler:
[{'random_time': '42 minuti fa'}]

It's working perfectly.

Here's the result on Pabbly Connect for the same code:
Error: name 'random_time' is not defined

Before the Pabbly Code update everything was working fine. In fact, I noticed that the Code I was using had "deprecated" in it so I updated Code and put the latest version in but it still doesn't work.

How can I solve it?

Thanks
 

Attachments

ArshilAhmad

Moderator
Staff member
I tried to run this code in an online compiler and got an error. I request you to please record a short video running the exact same code on Code by Pabbly and an online compiler.
1704386608310.png
 

inochi

Member
It's normal for it to give you an error.. you copied and pasted without formatting the Python code correctly.
Copy this code with the correct formatting from the following link:

Then try running the code through this compiler:

I am also attaching the video screen:

Let me know

Thank you
 

ArshilAhmad

Moderator
Staff member
Thank you for sharing the video. Please allow us some time to look into this concern. We will get back to you with an update soon.
 

inochi

Member
Okay, now it's working. What has changed? Can you give me specific directions so that all the codes work?
 

inochi

Member
Same issue with this code:

It's working well on Python compiler (see the screenshot) but it's giving me an error on Pabbly Connect...

Could you please help me?

Thanks
 

Attachments

Status
Not open for further replies.
Top