+ 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=" ")
9 odpowiedzi
+ 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
+ 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 ;)
+ 1
You're welcome; you have already helped me, you made me understand what the 3rd argument of range() was
0
What is this "range(0, len(a), 3):" ?
0
try to use it and you will understand it :)
try to use the code above
0
you can called it , Secret Agent code
0
Can you tell me an example with an input, your expected output, and the output the program gives please?
0
Either way, sick, I didn't know what the 3rd argument did in range() I'm greatful for learning something new
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.