"""Take the following Python code that stores a string:str = 'X-DSPAM-Confidence:0.8475'
Use find and string slicing to extract the portion of the string after
thecolon character and then use the float function to convert the extractedstring into a floating point number."""
str='X-DSPAM-Confidence:0.8475'
print('the length of the string is')
print(len(str))
p=str.find(":") #use find for find the ':'
print('the index of : is')
print(p)
print('the string before the colon is') #use slicing in the string
print(str[0:18])
print('the string after the colon is ') #using float function
q=float('0.8475')
print(q)
No comments:
Post a Comment