Answers for "TypeError: list indices must be integers or slices, not tuple"

1

TypeError: list indices must be integers or slices, not tuple

# Python Accessing List
numbers=[1,2,3,4]
print(numbers[0,3])
Posted by: Guest on September-25-2021
1

TypeError: list indices must be integers or slices, not builtin_function_or_method

months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
ordinalNumbers = ['1st', '2nd', '3rd', '4th', '5th', '6th', '7th', '8th', '9th', '10th', '11th', '12th', '13th', '14th', '15th', '16th', '17th', '18th', '19th', '20th', '21st', '22nd', '23rd', '24th', '25th', '26th', '27th', '28th', '29th', '30th', '31st']

# Get Date
def getDate():
    now = datetime.datetime.now()
    my_date = datetime.datetime.today()
    weekday = calendar.day_name[my_date.weekday]
    monthNum = now.month
    dayNum = now.day

    return ('Todays date is '+weekday+' '+months[monthNum -1]+' the '+ordinalNumbers[dayNum -1]+'.')

print(getDate())
Posted by: Guest on November-28-2020
0

TypeError: list indices must be integers or slices, not tuple

# Python Accessing List
numbers=[1,2,3,4]
print(numbers[0:3])
Posted by: Guest on September-25-2021

Code answers related to "TypeError: list indices must be integers or slices, not tuple"

Python Answers by Framework

Browse Popular Code Answers by Language