Issue with Python Code
Status: Closed · Asked by inochi on · 0 views
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

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.
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


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.
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:
https://pastebin.com/3jmx6xPh
Then try running the code through this compiler:
https://www.online-python.com/
I am also attaching the video screen:
https://cln.sh/Q6Xwn4gky2Drk49qRqYB
Let me know
Thank you
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, Please try using this code:
https://pastebin.com/0k7a0PMa
Okay, now it's working. What has changed? Can you give me specific directions so that all the codes work?
Same issue with this code:
https://pastebin.com/C49NsMqc
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


Please allow us some time to look into this issue. We will get back to you shortly.
We have made some changes at the backend. The code should work now.
It's working!
Thanks