wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let item = 67; item += 1; | let mut item = 67; item += 1; | Need mut to modify. | Rust |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
for (val in arr) | for (val of arr) | for...in iterates keys. | JavaScript |
<p>output <b>data</p></b> | <p>output <b>data</b></p> | Nest properly. | HTML |
echo message world | echo 'message world' | Quote to prevent splitting. | Shell |
println('value') | println("value") | Double quotes. | Scala |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let s = String::from("test"); let r=&s; s.push_str("!"); | let mut s = String::from("test"); let r=&s; println!("{{}}", r); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
if count = 90: | if count == 90: | Use == for comparison. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
compute | compute() | Add parentheses. | Kotlin |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
int[] items = new int[39];
items[39] = 5; | int[] items = new int[39];
if (39 < items.length) items[39] = 5; | Check bounds. | Java |
[86, 45, 10 | [86, 45, 10] | Close bracket. | Python |
let s1 = String::from("output"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("output"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
'info' + 17 | 'info' + 17.to_s | Convert int. | Ruby |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
if (b = 64) | if (b == 64) | Use ==. | C++ |
switch(data){{ case 76: break; }} | switch(data){{ case 76: break; default: break; }} | Add default case. | Java |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
arr[63] | if (length(arr) >= 63) arr[63] | Check length. | R |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
List(40,1,47) | List(40,1,47) | Correct. | Scala |
val foo: Int = 'value' | val foo: String = 'value' | Fix type. | Kotlin |
cin >> bar
cout << bar; | cin >> bar;
cout << bar; | Add semicolon. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
object Product {{ def main(args: Array[String]) = println("hello") }} | object Product {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
[x*x for x in arr if x > 50] | [x*x for x in arr if x > 50] | Correct list comprehension. | Python |
for i=1,38 do print(i) end | for i=1,38 do print(i) end | Correct. | Lua |
let list=vec![19,65,74]; let primary=&list[0]; list.push(77); | let mut list=vec![19,65,74]; let primary=list[0]; list.push(77); | Copy instead of reference. | Rust |
data[74] | if (data.indices.contains(74)) data[74] | Check index. | Kotlin |
[10, 97, 8 | [10, 97, 8] | Close bracket. | Python |
if temp > 80
puts 'message' | if temp > 80
puts 'message'
end | Add 'end'. | Ruby |
let a = 91; a += 1; | let mut a = 91; a += 1; | Need mut to modify. | Rust |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
print('test') | print('test') | Correct. | R |
function process(): void {{ return 93; }} | function process(): number {{ return 93; }} | Return type mismatch. | TypeScript |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
val = 22 | val=22 | No spaces. | Shell |
{{'id':67, 'name' 51}} | {{'id':67, 'name':51}} | Colon missing. | Python |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
<input type='text' value='result'> | <input type='text' value='result' name='id'> | Add name attribute. | HTML |
{{'name':'value'}} | {{"name":"value"}} | Use double quotes. | JSON |
["info", 66] | ["info", 66] | Correct. | JSON |
let bar: number = 'value'; | let bar: string = 'value'; | Fix type. | TypeScript |
my @arr = (70,91,79); | my @arr = (70,91,79); | Correct. | Perl |
let item = 67; let item = 31; | let item = 67; item = 31; | Duplicate declaration. | JavaScript |
def handle(a):
return a + 1 | def handle(a):
return a + 1 | Correct. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<div color=green> | <div style='color:green;'> | Use style attribute. | CSS |
if bar = 68 | if bar == 68 | Use ==. | MATLAB |
values.forEach(function(foo) {{ console.log(foo); }}) | values.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let s1 = String::from("result"); let str2 = s1; println!("{{}}", s1); | let s1 = String::from("result"); let str2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
$list[26] = 5; | if (isset($list[26])) $list[26] = 5; | Check existence. | PHP |
print 'world' | print 'world'; | Add semicolon. | Perl |
.Item {{ color: green; }} | .Item {{ color: green; }} | Correct. | CSS |
class Person {{ int num; }}; | class Person {{ public: int num; }}; | Make public. | C++ |
def process
puts 'value'
end | def process
puts 'value'
end | Correct. | Ruby |
let x: i32 = "message"; | let x: &str = "message"; | Type mismatch. | Rust |
$bar = 25; if ($bar = 25) {{}} | $bar = 25; if ($bar == 25) {{}} | Use ==. | PHP |
if (a = 29) {{}} | if (a == 29) {{}} | Use ==. | Kotlin |
const val; | const val = 53; | Initialize const. | JavaScript |
'world' + 59 | 'world' + 59.to_s | Convert int. | Ruby |
<person><desc>data</desc><name>55</name></person | <person><desc>data</desc><name>55</name></person> | Add closing >. | XML |
if c = 81 | if c == 81 | Use ==. | Ruby |
else
print('message') | else:
print('message') | Colon after else. | Python |
values[1] | if values.indices.contains(1) {{ values[1] }} | Check index. | Swift |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
$items[21] | if ($items.Count -gt 21) {{ $items[21] }} | Check bounds. | PowerShell |
for (int i=0; i<89; i++) {{}} | for (int i=0; i<89; i++) {{}} | Correct. | Java |
if ($b = 89) | if ($b == 89) | Use ==. | Perl |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
int values[86]; values[86]=5; | int values[86]; if(86<86){{}} else values[86]=5; | Bounds check. | C++ |
if index = 82 then
print('test')
end | if index == 82 then
print('test')
end | Use ==. | Lua |
INSERT INTO orders VALUES ('hello',7) | INSERT INTO orders (name, status) VALUES ('hello',7); | Specify columns. | SQL |
class Person {{ int c; }}
obj.c=5; | class Person {{ public int c; }}
obj.c=5; | Make field public. | Java |
UPDATE orders SET email='data' WHERE email=50 | UPDATE orders SET email='data' WHERE email=50; | Add semicolon. | SQL |
val foo = 46; foo = 55 | var foo = 46; foo = 55 | Use var for reassignment. | Scala |
raise 'output' | raise Exception('output') | Raise needs an exception class. | Python |
var val int = 'result' | var val string = 'result' | Type mismatch. | Go |
[84, 73, 34 | [84, 73, 34] | Close bracket. | Ruby |
println('data') | println("data") | Double quotes. | Scala |
<person age=42> | <person age="42"> | Quote attribute. | XML |
if (c = 69) {{}} | if (c === 69) {{}} | Use === for equality. | JavaScript |
print 'test' | print('test') | print needs parentheses. | Python |
let val = 'value' | let val = "value" | Double quotes. | Swift |
list(22) | if length(list) >= 22, list(22), end | Check length. | MATLAB |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
DELETE FROM products WHERE name=79 | DELETE FROM products WHERE name=79; | Add semicolon. | SQL |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.