'Skip Integers for lab activity

  1. Define a function named skip_integers, with a variable number of arguments.
  2. Use a for loop to iterate over the arguments.
  3. Use a check to see whether the value passed is of the integer type. If it is, use the continue statement to ignore it.
  4. Print the arguments.
def skip_integers(*args):
     for i in args:
         if i == (function)
         continue

skip_integers(3,5.2, "value", 6.0)

I cant figure this out at all can someone help me:(



Solution 1:[1]

The problem isn't with the code you've shown, so it must be with the if-statement. Not knowing what your function is doing, I created my own.

   def is_integer(num): 
        if type(num) == int:
            return True 
        else: 
            return False

You could also simplify this by adding the if statement in my function to your code like this.

    for i in args:
        if type(i) == int:
             continue

Solution 2:[2]

user_string = input()    # prompt the user to enter the string    
result = user_string.isdigit()    # check if the string is an integer string

if result:    # if result is true then print yes
    print("yes")
else:    # else if result is false then print no
   print("no")

Solution 3:[3]

this works:

def skip_integers(*args):
    args = list(args)
    for i in args:
        if type(i) == int:
            args.remove(i)
    return args

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Blake
Solution 2 ellhe-blaster
Solution 3