top of page

רעננו את הדף והקליקו למעבר לנושא הבא:

תרגיל מחרוזת (string)

Updated: Aug 15, 2021

תרגיל מחרוזת (string) -

א. הפכו את המספר 123456789 למחרוזת בתוך המשתנה x.

ב. כתבו תוכנית שתדפיס מתוך המחרוזת את המספרים 123 שלאחריהם 789 כך שתתקבל המחרוזת "123789"

הדרך הפשוטה לפתרון התרגיל -

x=str(123456789) print(x[0:4]+x[6::])

>>>

1234789

כדאי לשים לב ש- [::6] פירושו החל מהאיבר מספר 6 שהוא הספרה 7 היות שמתחילים את האינדקס מ- 0. ודאבל נקודתיים פירושן, עד הסוף.

 
 
 

Related Posts

See All

3 Comments


fairplay is a trusted platform offering smooth and secure access for users. With fairplay login, fairplay id, and the fairplay app, everything becomes easier and more convenient. The fairplay club adds exclusive rewards, making fairplay a reliable choice for many. https://fairpplay.com/

Like

fairplay is a trusted platform offering smooth and secure access for users. With fairplay login, fairplay id, and the fairplay app, everything becomes easier and more convenient. The fairplay club adds exclusive rewards, making fairplay a reliable choice for many.

Like

Break away from routine and explore fresh conversations with people across the globe. Whether you're bored, curious, or just seeking human connection, talk to strangers online and discover unexpected friendships or thrilling chats. It’s an exciting way to socialize safely and freely. Dive into the unknown and open your world to fascinating people.

Like
Single Post: Blog_Single_Post_Widget
bottom of page