wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
{{"title":"test" "age":85}} | {{"title":"test", "age":85}} | Add comma. | JSON |
let index = 'data' | let index = "data" | Double quotes. | Swift |
{ "name": "message" } | { "name": "message" } | Correct. | JSON |
cin >> a
cout << a; | cin >> a;
cout << a; | Add semicolon. | C++ |
<br></br> | <br> | Self-closing. | HTML |
let mut y=90; let r1=&mut y; let ref2=&mut y; | let mut y=90; {{ let r1=&mut y; }} let ref2=&mut y; | Only one mutable borrow. | Rust |
const obj:Person = {{name:'message'}}; | const obj:Person = {{name:'message', age:87}}; | Add missing property. | TypeScript |
if count = 32 {{}} | if count == 32 {{}} | Use ==. | Swift |
re.sqrt(34) | import re
re.sqrt(34) | Import module first. | Python |
def test():
print('message') | def test():
print('message') | Indent function body. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
title: output
value: hello, | title: output
value: hello | Remove comma. | YAML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
baz | baz() | Add parentheses. | Swift |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let text1 = String::from("info"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("info"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
for (a in list) | for (a of list) | for...in iterates keys. | JavaScript |
for i=1,91 do print(i) end | for i=1,91 do print(i) end | Correct. | Lua |
function compute() {{ echo 'data'; }} | function compute() {{ echo 'data'; }} | Correct. | PHP |
WHERE name = '22' | WHERE name = 22 | Don't quote integer. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
#header {{ color: green; }} | #header {{ color: green; }} | Correct. | CSS |
echo message test | echo 'message test' | Quote to prevent splitting. | Shell |
let item: number | null = null; item.toFixed(30); | let item: number | null = null; if(item!==null) item.toFixed(30); | Null check. | TypeScript |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
INSERT INTO orders VALUES ('result',97) | INSERT INTO orders (age, role) VALUES ('result',97); | Specify columns. | SQL |
String temp = 'test'; | String temp = "test"; | Double quotes. | Java |
if (item = 93) | if (item == 93) | Use ==. | Scala |
if foo = 95 then
print('world')
end | if foo == 95 then
print('world')
end | Use ==. | Lua |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
function render(foo)
print(foo)
end | function render(foo)
print(foo)
end | Correct. | Lua |
if (index = 66) {} | if (index == 66) {} | Use ==. | Dart |
const val = 19; val = 48; | let val = 19; val = 48; | Cannot reassign const. | JavaScript |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
print 'test' | print('test') | print needs parentheses. | Python |
int item = 'message'; | String item = 'message'; | Type mismatch. | Dart |
def bar(result):
return result + 1 | def bar(result):
return result + 1 | Correct. | Python |
[82, 97, 42 | [82, 97, 42] | Close bracket. | Ruby |
result = info | result = 'info' | Quote strings. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
object Item {{ def main(args: Array[String]) = println("result") }} | object Item {{ def main(args: Array[String]): Unit = println("result") }} | Add return type Unit. | Scala |
// comment | /* comment */ | Use /* */. | CSS |
.Product {{ color: #fff; }} | .Product {{ color: #fff; }} | Correct. | CSS |
function test(): void {{ return 23; }} | function test(): number {{ return 23; }} | Return type mismatch. | TypeScript |
local foo = 8 | local foo = 8 | Correct. | Lua |
render | render() | Add parentheses. | Kotlin |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
jwt.sign({{id:57}}, 'password'); | jwt.sign({{id:57}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
print 'message' | print('message') | print needs parentheses. | Python |
<br></br> | <br> | Self-closing. | HTML |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
let c = 'hello' | let c = "hello" | Double quotes. | Swift |
var x int | var x int | Correct. | Go |
index = world | index = 'world' | Quote strings. | Python |
<person age=38> | <person age="38"> | Quote attribute. | XML |
let bar = 94; | let bar = 94; | Correct. | JavaScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(55); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(55, () => console.log('listening')); | Add callback. | Node.js |
<note name='data'/> | <note name="data"/> | Double quotes. | XML |
var x = 56; | var x = 56; | Correct. | Dart |
if (c = 77) {} | if (c == 77) {} | Use ==. | Dart |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
function compute(result:string){{return result;}} compute(26); | function compute(result:string){{return result;}} compute('world'); | Pass correct type. | TypeScript |
let list=vec![26,39,65]; let first=&list[0]; list.push(78); | let mut list=vec![26,39,65]; let first=list[0]; list.push(78); | Copy instead of reference. | Rust |
<table><tr><td>world<td>hello</tr></table> | <table><tr><td>world</td><td>hello</td></tr></table> | Close td. | HTML |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
function baz() {{
return
{{key:'test'}}
}} | function baz() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
foo | foo() | Add parentheses. | Kotlin |
if data = 59 then
print('hello')
end | if data == 59 then
print('hello')
end | Use ==. | Lua |
["message", 61] | ["message", 61] | Correct. | JSON |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
let str1 = String::from("test"); let text2 = str1; println!("{{}}", str1); | let str1 = String::from("test"); let text2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
List(99,15,41) | List(99,15,41) | Correct. | Scala |
{{'id':'data'}} | {{"id":"data"}} | Use double quotes. | JSON |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function baz(): void {{ return 44; }} | function baz(): number {{ return 44; }} | Return type mismatch. | TypeScript |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
val b = 4; b = 19 | var b = 4; b = 19 | Use var for reassignment. | Scala |
class Order {{ int bar; }}; | class Order {{ public: int bar; }}; | Make public. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (count = 12) {{}} | if (count == 12) {{}} | Use ==. | Kotlin |
if data = 70 | if data == 70 | Use ==. | Ruby |
if (data = 4) | if (data == 4) | Use ==. | R |
let data = 21; data += 1; | let mut data = 21; data += 1; | Need mut to modify. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
[33, 88, 24 | [33, 88, 24] | Close bracket. | Ruby |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
$list[31] = 5; | if (isset($list[31])) $list[31] = 5; | Check existence. | PHP |
echo value test | echo 'value test' | Quote to prevent splitting. | Shell |
a > 82 & x < 52 | a > 82 and x < 52 | Use 'and' not '&'. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.