fork download
  1.  
  2. #lista = []
  3.  
  4. #for i in range(1, 100):
  5. # lista.append(i)
  6.  
  7. # list comprehension
  8.  
  9. #lista = [ x+3 for x in range(1, 10) ]
  10.  
  11. #lista = [ x for x in range(1, 10) if x < 5 ]
  12.  
  13. lista = [ x+3 for x in range(1, 10) if x < 5 ]
  14.  
  15. print(lista)
  16.  
  17. # Za pomocą list składanych (list comprehension), mając listę mebli,
  18. # stworzyć nową listę mebli zaczynających się na literę a.
  19.  
  20. meble = ["krzeslo", 'szafa', 'stol', 'krzeslo', 'abazur', 'szafa', 'antyk']
  21.  
  22. meble_a = [ x for x in meble if x.startswith("a") ]
  23.  
  24. print( meble_a )
  25.  
  26. napis = """
  27. MOJ NAPIS
  28. a
  29. b
  30. """
  31.  
  32. print(napis)
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
Success #stdin #stdout 0.02s 9392KB
stdin
Standard input is empty
stdout
[4, 5, 6, 7]
['abazur', 'antyk']

MOJ NAPIS 
a
b