I am trying to get my code to identify everything in my array however what I thought you should do is not working...Any suggestions???
Here is my code:
version = ['4','4s','5','5C','5S','6','6 Plus','6+','6S','6S', Plus','6S+','SE','7','7 Plus','7+']
if make == version[0-14]:
print (m
I think what you're trying to do is see if make
is in your list. The way you do this in Python is with the in
operator:
version = ['4','4s','5','5C','5S','6','6 Plus','6+','6S','6S', 'Plus','6S+','SE','7','7 Plus','7+']
if make in version:
print (make)
try:
m = '4'
if any([m == v for v in version[0:14]]):
print(m)
It's not entirely clear what you are trying to accomplish from your sample. Are you just trying to see if the value of make
exists in the version
list? If so, change this:
if make == version[0-14]:
to this:
if make in version:
There is missing a ' in front of the second "Plus"
version = ['4','4s','5','5C','5S','6','6 Plus','6+','6S','6S', 'Plus','6S+','SE','7','7 Plus','7+']
if make == version[0-14]:
print (m
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.