Skip to main content
deleted 16 characters in body
Source Link

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimateThe answer for itcould be:

spam = ['a', 'e', 'i', 'o', 'u']
if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[-1])

if your list is always >1 you can skip the if/else statement

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimate answer for it:

spam = ['a', 'e', 'i', 'o', 'u']
if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[-1])

if your list is always >1 you can skip the if/else statement

most people here are using things not thaught in the book such as join, join should not be used to solve this question. The answer could be:

if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[-1])

if your list is always >1 you can skip the if/else statement

added 61 characters in body
Source Link

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimate answer for it:

spam = ['a', 'e', 'i', 'o', 'u']
if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[-1])

if your list is always >1 you can skip the if/else statement

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimate answer for it:

spam = ['a', 'e', 'i', 'o', 'u']
if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[-1])

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimate answer for it:

spam = ['a', 'e', 'i', 'o', 'u']
if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[-1])

if your list is always >1 you can skip the if/else statement

added 63 characters in body
Source Link

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimate answer for it:

spam = ['a', 'e', 'i', 'o', 'u']
if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[len(spam)spam[-1])

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimate answer for it:

spam = ['a','e','i','o','u']
for i in range(len(spam)-1):
    print(spam[i],end=', ')
print('and', spam[len(spam)-1])

most people here are using things not thaught in the book such as join, join should not be used to solve this question. Here is the ultimate answer for it:

spam = ['a', 'e', 'i', 'o', 'u']
if len(spam) == 1:
    print(spam[0])
else:
    for i in range(len(spam)-1):
        print(spam[i], end=', ')
print('and', spam[-1])
deleted 17 characters in body
Source Link
Loading
added 33 characters in body
Source Link
Loading
Source Link
Loading