Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

why the indentation of line 38 is wrong? RA KY ESICNIC E E >> /Users/xinkuangshenyi/Downloads/ps2pr6.py ab1task2... sOpr3... os 1pr5... s1pr3... ps1pr2.. s1pr6... s2pr3... / /Users/xinkuangshenyi/Downloads

why the indentation of line 38 is wrong?

image text in transcribed

RA KY ESICNIC E E >> /Users/xinkuangshenyi/Downloads/ps2pr6.py ab1task2... sOpr3... os 1pr5... s1pr3... ps1pr2.. s1pr6... s2pr3... / /Users/xinkuangshenyi/Downloads Source Editor Object s2pr4.. s2pr6... listwords # # ps2pr6.py - Problem Set 2, Problem 6 # # list comprehensions # Built-in mutable sequence. if no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. # Problem 6-1: LC puzzles! # This code won't work until you complete the list comprehensions! # If you can't figure out how to complete one of them, please # comment out the corresponding lines by putting a # at the start # of the appropriate lines. # part a lci = ( x*2 for x in range(5)] # part b words = ('hello', 'world', 'how', 'goes', 'it?'] 1c2 = [ W[1] for w in words) Console 1/A SyntaxError: invalid syntax # part c 1c3 = [ word[::-1]+word [::-1] for word in ('hello', 'bye', 'no']] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 # part d 1c4 = ( x ** 2 for x in range(1, 10) if x^2==0 ] >>> runfile('/Users/xinkuangshenyi/Downloads/ps2pr6.py', wdir='/Users/xinkuangshenyi/Downloads) File "/Users/xinkuangshenyi/Downloads/ps2pr6.py", line 38 def shorter_than(n, wordlist) SyntaxError: invalid syntax # part e 1c5 = [ True if c in 'bu' else false for c in 'bu be you'] # Problem 6-2: Put your definition of the function below. def powers_of(base, count): "return a list containing the first count powers of base, beginning with the @th power input:a number base and a positive integer count" return [[base** x for x in range(count)] # def shorter_than(n, wordlist) listwords = [] for i in range(len(wordlist)): if len (wordlist[i])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

Students also viewed these Databases questions

Question

3. The group answers the questions.

Answered: 1 week ago