Answer to Question #167987 in Python for P

Question #167987

heck values in the Array is a String

Given an array

myArray, write a Python program to check whether each value of the array is a string or not .


Input:

  • The input will be a single line containing an array myArray

Output

  • The output should be a single line containing a boolean value


input:

["apple","goa","hyderabad"]

output:

true


input:

["dog","fox","70","movie"]

output:

false





1
Expert's answer
2021-03-03T16:22:54-0500
myArray1=["apple","goa","hyderabad"]
myArray2=["dog","fox","70","movie"]

def check_int_in_str(lis):
  for n in lis:
    try:
      float(n)
      l = 'False'
      print(l)
      break
    except (ValueError, TypeError):
      l = 'True'
  if l=='True':
    print(l)

check_int_in_str(myArray1)
check_int_in_str(myArray2)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS