+ 1

Hi everyone , i have some kind of problem with space , how could i fix it

#Hi everyone , i have some kind of problem with space , how could i fix it # you can use this code (cxohawalkldflghemwnsegfaeap) a = input("Message? ") for i in range(0, len(a), 3): b = a[i] print(b.rstrip() , end=" ")

27th Jun 2019, 12:37 AM
Khalid Saud
Khalid Saud - avatar
9 ответов
+ 2
You have to reformat it; whenever you print a newline will be automatically created, and in a for loop that's what you do, you are printing and adding newlines over and over again. Perhaps you have to "print(a[i]).rstrip()" As I didn't test that it may not work, and the solution would be to convert that into a function, with a string as a prototype, create a variable b and inside it, then make a for loop and inside the for loop make b += a[i] + " " and finally return b
27th Jun 2019, 2:12 AM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
+ 1
a = input("Message? ") b = '' for i in range(0, len(a), 3): b += a[i] + " " print(b.rstrip()) ================= thank you my friend for help me , and i looking forward to help you some day , but as you see i still beginner ;)
27th Jun 2019, 2:22 AM
Khalid Saud
Khalid Saud - avatar
+ 1
You're welcome; you have already helped me, you made me understand what the 3rd argument of range() was
27th Jun 2019, 2:26 AM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
0
What is this "range(0, len(a), 3):" ?
27th Jun 2019, 1:31 AM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
0
try to use it and you will understand it :) try to use the code above
27th Jun 2019, 1:37 AM
Khalid Saud
Khalid Saud - avatar
0
you can called it , Secret Agent code
27th Jun 2019, 1:40 AM
Khalid Saud
Khalid Saud - avatar
0
Can you tell me an example with an input, your expected output, and the output the program gives please?
27th Jun 2019, 1:48 AM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
0
Either way, sick, I didn't know what the 3rd argument did in range() I'm greatful for learning something new
27th Jun 2019, 1:50 AM
alvaro.pkg.tar.zst
alvaro.pkg.tar.zst - avatar
0
if input = cxohawalkldflghemwnsegfaeap output will be like this c h a l l e n g e ========== The code is fairly simple – you just need to select every third letter out of a sentence (starting from the first letter), and print out those letters with spaces in between them.
27th Jun 2019, 1:58 AM
Khalid Saud
Khalid Saud - avatar