Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
list and operator *
#1
hi
I saw the below snippet cod in a quiz on the net:
my_list=[1,2,3]
print(my_list*3)
print(3*my_list)
in that quiz, the output of line 2 had been required.
my question:
how can I know that an operator such as(+,*,- or /) can be used with a type( as string, list, tuple,...) and what is the result of it?
thanks
Reply
#2
Here: https://docs.python.org/3/library/stdtyp...uple-range

How I navigate through the Docs to find this information:
Python 3.12.2 documentation » Library Reference » Built-in Types » Sequence Types — list, tuple, range
akbarza likes this post
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020