+ 7
Hi,Why it doesn't work?
clrval must be string. When I wrote str(clrval), ['100','200','f9'] is appeared, r(00),g(00) doesn't work. in line 44 https://code.sololearn.com/cROJ0e2k9X92/?ref=app
9 Respostas
+ 13
Egor Tonchev(EGO) ,
just to mention, that there is a hex() function in python that can generate hex values from integers. but it is always a good idea to know how it can be done without built-in function 👍
inp = 67
print(hex(inp)) # result is: 0x42
+ 9
Abhay ,thank you very much
+ 9
Pallavi Bhardwaj ,thanks.
+ 8
Lothar ,Thank You 👍☺️
+ 7
I don't want to copy nothing.
+ 7
There is an indentation problem with your code , while loop is possibly outside for loop , so only last value gets encoded and other first two remain integer not string.
+ 4
Works fine after indenting it properly,
for j in range(3): clrval.append(int(input()))
for val in clrval:
index=clrval.index(val)
assert(0<=val<=255)
hexval=""
while val>0:
rmndr=val % 16
hexval += rplce.get(rmndr,str(rmndr))
val //= 16
hexval="".join(reversed(hexval))
clrval[index]=hexval
hexcodend="#"+"".join(clrval)
#hexcodend.split(",")
print(hexcodend)
+ 3
Maybe because you do not know how to copy other people's codes?☺️