+ 1
my code isnât working can someone give me tips?
i wanted to code something cool for python so i asked chatgpt and it gave me a rainbow text code and i copied the text (not copy and paste i texted in what i saw) and i still dont know whatâs wrong with it. https://sololearn.com/compiler-playground/cNbdPPjdu09T/?ref=app
3 Answers
+ 8
Your code is "mostly" working, yet showing signs you lack of basic concepts about python, such as how to name a variable and the use of indentation.
This is the modified code, however it won't run correctly in SL. For it to run correctly, you have to install Python on your computer and run it from the terminal / command prompt.
You can read the comments inside the code and know what went wrong. But I strongly suggest you keep doing the "Python Developer" course to learn it step by step.
https://sololearn.com/compiler-playground/clPBzv3gS4eQ/?ref=app
+ 1
Hi ,
I have check the code you have share. Please check correct form:-
import time
import sys
colors = [
'\033[91m', # red
'\033[93m', # yellow
'\033[92m', # green
'\033[96m', # cyan
'\033[94m', # blue
'\033[95m', # magenta
]
reset = '\033[0m'
def rainbow_text(text):
for i, char in enumerate(text):
color = colors[i % len(colors)]
sys.stdout.write(color + char + reset)
sys.stdout.flush()
time.sleep(0.05)
print()
rainbow_text("Python is awesome!")
Thanks in Advance!
Kamal Hinduja Geneva, Switzerland
0
https://sololearn.com/compiler-playground/cxkIwdw9Af1x/?ref=app
This is the updated code , there are few issues in your code like indentation,(space) , variable name and for learning basics you should explore real python.com , quickref