+ 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

7th Jul 2021, 9:27 AM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
9 Respuestas
+ 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
7th Jul 2021, 11:05 AM
Lothar
Lothar - avatar
+ 9
Abhay ,thank you very much
7th Jul 2021, 10:35 AM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
8th Jul 2021, 8:06 AM
Pallavi Bhardwaj
Pallavi Bhardwaj - avatar
+ 9
8th Jul 2021, 12:39 PM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
+ 8
Lothar ,Thank You 👍☺️
7th Jul 2021, 11:11 AM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
+ 7
I don't want to copy nothing.
7th Jul 2021, 10:02 AM
Egor Tonchev(EGO)
Egor Tonchev(EGO) - avatar
+ 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.
7th Jul 2021, 10:02 AM
Abhay
Abhay - avatar
+ 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)
7th Jul 2021, 10:04 AM
Abhay
Abhay - avatar
+ 3
Maybe because you do not know how to copy other people's codes?☺️
7th Jul 2021, 9:59 AM
Solo
Solo - avatar