6th Apr 2023, 10:24 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
20 Respuestas
+ 1
def newline(): age1 = 12 age2 = 23 age3 = 15 age4 = 16 name_age = [age1, age2, age3 , age4]; for index in range(len(name_age)): print(name_age[index]); newline(); This code is working fine. There is no problem or you didn't define your problem clearly.
8th Apr 2023, 1:15 AM
Raja Irfan Ahmed
Raja Irfan Ahmed - avatar
+ 7
Thile Dorje Lama , this is a complete *re-post* from you that was already posted same days ago. you may have *deleted* the former post, since nobody has given you a *ready-made code*. for this former post i have asked you to show a *serious code try* done by yourself. this is still pending !!
6th Apr 2023, 10:49 AM
Lothar
Lothar - avatar
+ 6
Thile Dorje Lama , *this is the question you have posted initially* : age = ('she', 12, 'he', 23, 'I', 15, 'you', 16) # result should print out with new line, like this # she 12 # he 23 # I 15 # you 16 >>> now you have *overwritten* this by a code sample that has *no relation* to the initial question. ??? how can you expect to get useful help by creating such a chaos ???
8th Apr 2023, 6:29 AM
Lothar
Lothar - avatar
+ 5
Thile Dorje Lama , show us your try so that we can see what the issue is. hint: we can achieve the task by using a for loop.
6th Apr 2023, 10:56 AM
Lothar
Lothar - avatar
+ 4
Thile Dorje Lama Use for loop and check if type of value is int then print new line.
6th Apr 2023, 11:37 AM
A͢J
A͢J - avatar
+ 3
Thile Dorje Lama Read about print, list slicing, for loops, range, variables and index in SoloLearns Python course. Then: Use slices to get two element at the time from the list. Use the for loop to change the indices in the list slice. Use range in the for loop to get only even indices to changing the slice index. And then print the elements for the sliceced list at every loop.
6th Apr 2023, 11:34 AM
Per Bratthammar
Per Bratthammar - avatar
+ 3
How did you try can you show?
6th Apr 2023, 12:08 PM
A͢J
A͢J - avatar
+ 3
Thile Dorje Lama I think this was not your actual requirement. in first requirement you had only one list but here two different list.
8th Apr 2023, 11:14 AM
A͢J
A͢J - avatar
+ 2
Yes but first you need to show your attempt so we can tell where is the issue
7th Apr 2023, 7:20 AM
A͢J
A͢J - avatar
+ 2
Asim Farheen.{-<-{R #, P #, R #, P# & KP#}->-} Don't copy question to give answer.
7th Apr 2023, 5:23 PM
A͢J
A͢J - avatar
+ 2
# DIVYANSH VIDHANI ! # If you have two collections, it’s more easy to do like this: ages = 12, 23, 15, 16 pronouns = 'she', 'he', 'I', 'you' for x, y in zip(pronouns, ages): print(x, y)
8th Apr 2023, 2:52 PM
Per Bratthammar
Per Bratthammar - avatar
+ 1
Solution: def newline(): age1 = 12 age2 = 23 age3 = 15 age4 = 16 name_age = [age1, age2, age3 , age4] l=["she","he","I","you"] for index in range(len(name_age)): print(l[index],name_age[index]) newline()
8th Apr 2023, 9:18 AM
DIVYANSH VIDHANI
DIVYANSH VIDHANI - avatar
0
Example
6th Apr 2023, 10:30 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
0
I could solve it
6th Apr 2023, 10:51 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
0
I mean I couldn't solve it
6th Apr 2023, 10:51 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
0
def newline(age): age = ['she', 12, 'he', 23, 'I', 15, 'you', 16] print(age) # result should print out in this way. she 12 he 23 I 15 you 16 # not in this way. she 12, he, 23, I, 15, you, 16
6th Apr 2023, 11:00 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
0
It's strange that you have completely completed the basic course in Python and can not solve such a simple problem... 🤔
6th Apr 2023, 11:09 AM
Solo
Solo - avatar
0
I tried but couldn't solve
6th Apr 2023, 11:43 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
0
I really need help over my question Can anyone please help me over
7th Apr 2023, 5:42 AM
Thile Dorje Lama
Thile Dorje Lama - avatar
0
Thanks
8th Apr 2023, 9:37 AM
Thile Dorje Lama
Thile Dorje Lama - avatar