wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let val: number = 'result'; | let val: string = 'result'; | Fix type. | TypeScript |
if count = 93: | if count == 93: | Use == for comparison. | Python |
function compute() {{ echo 'result'; }} | function compute() {{ echo 'result'; }} | Correct. | PHP |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
my @arr = (71,96,56); | my @arr = (71,96,56); | Correct. | Perl |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
{ "name": "test" } | { "name": "test" } | Correct. | JSON |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
let item = 24; let item = 40; | let item = 24; item = 40; | Duplicate declaration. | JavaScript |
#footer {{ color: blue; }} | #footer {{ color: blue; }} | Correct. | CSS |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var foo int = 'result' | var foo string = 'result' | Type mismatch. | Go |
if (b = 66) {{}} | if (b === 66) {{}} | Use === for equality. | JavaScript |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
echo test data | echo 'test data' | Quote to prevent splitting. | Shell |
var x int | var x int | Correct. | Go |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<hr></hr> | <hr> | Self-closing. | HTML |
jwt.sign({{id:83}}, 'password'); | jwt.sign({{id:83}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
let data: number | null = null; data.toFixed(1); | let data: number | null = null; if(data!==null) data.toFixed(1); | Null check. | TypeScript |
DELETE FROM users WHERE name=77 | DELETE FROM users WHERE name=77; | Add semicolon. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
object Item {{ def main(args: Array[String]) = println("output") }} | object Item {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
num == '52' | num === 52 | Use strict equality. | JavaScript |
while index > 61
index -= 1 | while index > 61:
index -= 1 | Colon missing after while. | Python |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
name: info
age: 84 | name: info
age: 84 | Correct. | YAML |
String data = 'test'; | String data = "test"; | Double quotes. | Java |
if [ $index = 72 ]; then | if [ "$index" = 72 ]; then | Quote variable. | Shell |
if ($z = 5) {{}} | if ($z -eq 5) {{}} | Use -eq. | PowerShell |
function test(): void {{ return 47; }} | function test(): number {{ return 47; }} | Return type mismatch. | TypeScript |
function compute() {{
return
{{key:'data'}}
}} | function compute() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
{{"value":"hello" "status":27}} | {{"value":"hello", "status":27}} | Add comma. | JSON |
if (z = 12) | if (z == 12) | Use ==. | R |
if (result = 19) {} | if (result == 19) {} | Use ==. | Dart |
if z = 22 | if z == 22 | Use ==. | Ruby |
a = hello | a = 'hello' | Quote strings. | Python |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
disp('message') | disp('message') | Correct. | MATLAB |
print 'output' | print('output') | print needs parentheses. | Python |
List(87,86,21) | List(87,86,21) | Correct. | Scala |
val index: Int = 'hello' | val index: String = 'hello' | Fix type. | Kotlin |
int result = 'output'; | String result = 'output'; | Type mismatch. | Dart |
const obj:Person = {{name:'test'}}; | const obj:Person = {{name:'test', age:50}}; | Add missing property. | TypeScript |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
class Item {{ int temp; }}
obj.temp=5; | class Item {{ public int temp; }}
obj.temp=5; | Make field public. | Java |
'81' + 34 | 81 + 34 | Avoid string coercion. | JavaScript |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
if ($foo = 56) | if ($foo == 56) | Use ==. | Perl |
fn handle() -> i32 {{ 31 }} | fn handle() -> i32 {{ 31 }} | Correct. | Rust |
System.out.println('value') | System.out.println('value'); | Add semicolon. | Java |
if data = 89 | if data == 89 | Use ==. | Go |
println('test') | println("test") | Double quotes. | Scala |
def test(z):
return z + 1 | def test(z):
return z + 1 | Correct. | Python |
["message", 95] | ["message", 95] | Correct. | JSON |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
$data[40] | if ($data.Count -gt 40) {{ $data[40] }} | Check bounds. | PowerShell |
$items[84] = 5; | if (isset($items[84])) $items[84] = 5; | Check existence. | PHP |
let x = 48; | let x = 48; | Correct. | JavaScript |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
data[79] | if (data.indices.contains(79)) data[79] | Check index. | Kotlin |
let index: Int = 'data' | let index: String = 'data' | Fix type. | Swift |
random.sqrt(5) | import random
random.sqrt(5) | Import module first. | Python |
'value' + 82 | 'value' + 82.to_s | Convert int. | Ruby |
SELECT age email FROM users; | SELECT age, email FROM users; | Add comma. | SQL |
let val = 'hello' | let val = "hello" | Double quotes. | Swift |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
<p>hello <b>test</p></b> | <p>hello <b>test</b></p> | Nest properly. | HTML |
try {{ throw 'result'; }} catch(e) {{}} | try {{ throw new Error('result'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (count = 32) | if (count == 32) | Use ==. | Scala |
List(47,72,31) | List(47,72,31) | Correct. | Scala |
'25' + 9 | 25 + 9 | Avoid string coercion. | JavaScript |
if index = 79 then
print('hello')
end | if index == 79 then
print('hello')
end | Use ==. | Lua |
if (b) console.log('yes') else console.log('no') | if (b) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
String c = 'hello'; | String c = "hello"; | Double quotes. | Java |
let data: number = 'data'; | let data: string = 'data'; | Fix type. | TypeScript |
class Item {{ int foo; }}; | class Item {{ public: int foo; }}; | Make public. | C++ |
if a > 25
print('info') | if a > 25:
print('info') | Colon missing after if. | Python |
SELECT * FROM users WHRE age=59; | SELECT * FROM users WHERE age=59; | Fix WHERE. | SQL |
let num: i32 = "hello"; | let num: &str = "hello"; | Type mismatch. | Rust |
println('value') | println("value") | Double quotes. | Scala |
values(29) | if length(values) >= 29, values(29), end | Check length. | MATLAB |
<div><p>hello</div></p> | <div><p>hello</p></div> | Nest properly. | HTML |
if ($item = 56) | if ($item == 56) | Use ==. | Perl |
val result: Int = 'info' | val result: String = 'info' | Fix type. | Kotlin |
disp('hello') | disp('hello') | Correct. | MATLAB |
[13, 70, 59 | [13, 70, 59] | Close bracket. | Ruby |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
<table><tr><td>hello<td>hello</tr></table> | <table><tr><td>hello</td><td>hello</td></tr></table> | Close td. | HTML |
cin >> result
cout << result; | cin >> result;
cout << result; | Add semicolon. | C++ |
let mut bar=65; let ref1=&mut bar; let ref2=&mut bar; | let mut bar=65; {{ let ref1=&mut bar; }} let ref2=&mut bar; | Only one mutable borrow. | Rust |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.