+ 3

Very Simple Python Problem - Help?

Hello everyone, I’m stuck on a string problem in the python for beginners course. It looks like my code output is the same as the desired result but it is incorrect somehow. This is my code: Print (“* \n** \n*** \n****”) My output: * ** *** **** Desired output: * ** *** **** How can I correct my code? I’ve checked to make sure there are no additional spaces as well. Thank you! Ryan

31st Oct 2021, 5:49 PM
Ryan Grant
Ryan Grant - avatar
2 Respostas
+ 8
Ryan Grant , this is the code that is provided from sololearn: print("* ** *** ****") most of the users insert new-line sequences '\n', but do not remove the spaces. this creates a problem in the code coach test cases. so we have to remove ALL spaces in the string!
31st Oct 2021, 9:01 PM
Lothar
Lothar - avatar
+ 4
Sometimes sololearn is a little buggy and just running it again makes one pass the test cases. 🤷‍♀️ edit: in your code example, there seem to be white spaces before \n. Did you remove them in your actual code?
31st Oct 2021, 6:09 PM
Lisa
Lisa - avatar