wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
let text = String::from("test"); let borrow=&text; text.push_str("!"); | let mut text = String::from("test"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
class Person {{ int z; }}; | class Person {{ public: int z; }}; | Make public. | C++ |
var x = 85; | var x = 85; | Correct. | Dart |
<input type='text' value='data'> | <input type='text' value='data' name='title'> | Add name attribute. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
while z > 28
z -= 1 | while z > 28:
z -= 1 | Colon missing after while. | Python |
if count = 78 | if count == 78 | Use ==. | Ruby |
for (int i=0; i<75; i++) {{}} | for (int i=0; i<75; i++) {{}} | Correct. | Java |
assert x > 84 | assert x > 84 | Correct. | Python |
arr(62) | if length(arr) >= 62, arr(62), end | Check length. | MATLAB |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
local result = 67 | local result = 67 | Correct. | Lua |
let index: number = 'output'; | let index: string = 'output'; | Fix type. | TypeScript |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
for y in range(38)
print(y) | for y in range(38):
print(y) | Colon after for. | Python |
<user><desc>result</desc><name>13</name></user | <user><desc>result</desc><name>13</name></user> | Add closing >. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
def bar
puts 'result'
end | def bar
puts 'result'
end | Correct. | Ruby |
Write-Host 'message' | Write-Host 'message' | Correct. | PowerShell |
let num = 66; let num = 56; | let num = 66; num = 56; | Duplicate declaration. | JavaScript |
x := 25 | x := 25 | Correct. | Go |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var result int = 'world' | var result string = 'world' | Type mismatch. | Go |
for (item in arr) | for (item of arr) | for...in iterates keys. | JavaScript |
print 'world' | print('world') | print needs parentheses. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
let a = 'data' | let a = "data" | Double quotes. | Swift |
let count: number | null = null; count.toFixed(44); | let count: number | null = null; if(count!==null) count.toFixed(44); | Null check. | TypeScript |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
$y = 73; if ($y = 73) {{}} | $y = 73; if ($y == 73) {{}} | Use ==. | PHP |
function handle(count)
print(count)
end | function handle(count)
print(count)
end | Correct. | Lua |
String name = 'test'; | String name = 'test'; | Correct. | Dart |
function handle() {{ echo 'test'; }} | function handle() {{ echo 'test'; }} | Correct. | PHP |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
def process():
print('test') | def process():
print('test') | Indent function body. | Python |
function compute() {{
return
{{key:'result'}}
}} | function compute() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{'age':'message'}} | {{"age":"message"}} | Use double quotes. | JSON |
if ($num = 12) | if ($num == 12) | Use ==. | Perl |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
if (item = 68) | if (item == 68) | Use ==. | C++ |
name: test
age: 20 | name: test
age: 20 | Correct. | YAML |
<person age=66> | <person age="66"> | Quote attribute. | XML |
int list[39]; list[39]=5; | int list[39]; if(39<39){{}} else list[39]=5; | Bounds check. | C++ |
json.sqrt(52) | import json
json.sqrt(52) | Import module first. | Python |
const x; | const x = 99; | Initialize const. | JavaScript |
let text1 = String::from("output"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
index == '66' | index === 66 | Use strict equality. | JavaScript |
if y = 7 | if y == 7 | Use ==. | MATLAB |
if (count = 48) {} | if (count == 48) {} | Use ==. | Dart |
["output", 17] | ["output", 17] | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
let c = 57; c += 1; | let mut c = 57; c += 1; | Need mut to modify. | Rust |
DELETE FROM items WHERE age=83 | DELETE FROM items WHERE age=83; | Add semicolon. | SQL |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
SELECT * FROM products WHRE status=39; | SELECT * FROM products WHERE status=39; | Fix WHERE. | SQL |
object Product {{ def main(args: Array[String]) = println("output") }} | object Product {{ def main(args: Array[String]): Unit = println("output") }} | Add return type Unit. | Scala |
list.forEach(function(b) {{ console.log(b); }}) | list.forEach((b) => {{ console.log(b); }}) | Arrow functions are cleaner. | JavaScript |
else
print('result') | else:
print('result') | Colon after else. | Python |
<div><p>info</div></p> | <div><p>info</p></div> | Nest properly. | HTML |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
<br></br> | <br> | Self-closing. | HTML |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
[11, 33, 58 | [11, 33, 58] | Close bracket. | Ruby |
if (foo = 21) | if (foo == 21) | Use ==. | R |
val item = 53; item = 41 | var item = 53; item = 41 | Use var for reassignment. | Scala |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
yield result | yield result | Correct yield. | Python |
<hr></hr> | <hr> | Self-closing. | HTML |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
int[] values = new int[39];
values[39] = 5; | int[] values = new int[39];
if (39 < values.length) values[39] = 5; | Check bounds. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
let data = 56; | let data = 56; | Correct. | JavaScript |
value: hello
status: hello, | value: hello
status: hello | Remove comma. | YAML |
[x*x for x in arr if x > 93] | [x*x for x in arr if x > 93] | Correct list comprehension. | Python |
if index = 93 | if index == 93 | Use ==. | Go |
let data: Int = 'result' | let data: String = 'result' | Fix type. | Swift |
List(81,23,70) | List(81,23,70) | Correct. | Scala |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
function baz(): void {{ return 34; }} | function baz(): number {{ return 34; }} | Return type mismatch. | TypeScript |
function test(num:string){{return num;}} test(27); | function test(num:string){{return num;}} test('world'); | Pass correct type. | TypeScript |
int data = 'output'; | String data = 'output'; | Type mismatch. | Dart |
INSERT INTO items VALUES ('message',100) | INSERT INTO items (age, email) VALUES ('message',100); | Specify columns. | SQL |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
jwt.sign({{id:7}}, 'key'); | jwt.sign({{id:7}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
$items[5] | if ($items.Count -gt 5) {{ $items[5] }} | Check bounds. | PowerShell |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
$result = 5; if ($result = 5) {{}} | $result = 5; if ($result == 5) {{}} | Use ==. | PHP |
arr[58] | if (arr.indices.contains(58)) arr[58] | Check index. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
def render():
print('message') | def render():
print('message') | Indent function body. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.