Difference between revisions of "Python Problems and Solutions"

From rbachwiki
Jump to navigation Jump to search
Line 1: Line 1:
<pre>
<pre>
st = 'Print only the words that start with s in this sentence'
st = 'Print only the words that start with s in this sentence'
for word in (st.split()):
for word in st.split():
     if word[0]== 's':
     if word[0].lower()== 's':
     print(word)
     print(word)
</pre>
</pre>
Use Range() to print all even numbers from 0 to 10
for num in range(0,11,2):
  print(num)

Revision as of 21:17, 2 February 2019

st = 'Print only the words that start with s in this sentence'
for word in st.split():
    if word[0].lower()== 's':
     print(word)

Use Range() to print all even numbers from 0 to 10

for num in range(0,11,2):
  print(num)