CodeSolved

A comprehensive source of programming questions and exercises

Summary of the text

Practice Easy 34/ Download 1385 Views

Write a function that receives a text and returns the first 100 characters with "..." if the text is longer than 100 characters. Otherwise it will restore the whole text unchanged.

16 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
import math as m
def matn(m):
    # Check whether the text is 100 characters
    if len(m) >= 100 :
        return m[:100] + "..."
    else :
        return m
matnvorodi=input('matn morede nazar ra vared konid:')
print(matn(matnvorodi))
Chef.nasim Download Python
def short(x):
    if len(x) > 100:
        b = x[:100+1] + '...'
        return b
    else:
        return x
txt = input('text: ')
print(short(txt))
def short_passage(passage):
  if len(passage) > 100:
    shorted_passage = passage[0:100] 
    return shorted_passage
  else:
    return passage

def main():
  passage = input("please Enter your passage: ")
  editted_passage = short_passage(passage)
  #print("«" + editted_passage + "»" )
  print(f"«{editted_passage}»")

if __name__ == "__main__":
  main()
User 2637 Download Python
def short_String(string):
    if len(string) > 100:
        return string[0:100] + "..."
    else:
        return string
num = input('string: ')
print(short_String(num))
Nima1393 Download Python
def matn():
    str = input("please enter a string: ")
    if len(str) > 100:
        print (str[0: 100], "...")
    else:
        print(str)
    print(len(str))
matn()
def text(t):
    if len(t) > 100:
        return t[:100] + "..."
    else:
        return t
text(input("Enter :"))
print(text)
def tix (tx):
         if len(tx)>10:
            return (tx[:10],'...')
         return tx
d=input('tx:')
print(tix(d))
Maryam.n Download Python
<< Previous page 1 2 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close