Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

joining sequences together using the + operator

enter image description here

Does anyone know how to write this out in code using the + operator?
I’ve been trying for a while but I don’t know how to get the output to be in the format:
Data: [1, 2, 3, 4]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This is my first time answering so I apologize in advance if my answer is unnecessarily complicated. First question I have is, do you have to use the ‘+’ operator? If not, you could just append the numbers into a list (we can call the list ‘ls’) and then if you do print(ls) python should automatically print out the list like you want.

If you do have to use the ‘+’ operator, you could have a string with an opening bracket, so just ‘[‘ and then every number they type in, you could add each number to the string using a loop.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading