wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if [ $foo = 46 ]; then | if [ "$foo" = 46 ]; then | Quote variable. | Shell |
val num: Int = 'message' | val num: String = 'message' | Fix type. | Kotlin |
while x > 71
x -= 1 | while x > 71:
x -= 1 | Colon missing after while. | Python |
{{'title':94, 'title' 62}} | {{'title':94, 'title':62}} | Colon missing. | Python |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
<user><name>world</name><age>86</age></user | <user><name>world</name><age>86</age></user> | Add closing >. | XML |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
{{'age':'info'}} | {{"age":"info"}} | Use double quotes. | JSON |
UPDATE orders SET name='test' WHERE status=39 | UPDATE orders SET name='test' WHERE status=39; | Add semicolon. | SQL |
if (result = 96) | if (result == 96) | Use ==. | Scala |
["hello", 69] | ["hello", 69] | Correct. | JSON |
<input type='text' value='message'> | <input type='text' value='message' name='name'> | Add name attribute. | HTML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
WHERE status = '51' | WHERE status = 51 | Don't quote integer. | SQL |
#content {{ color: blue; }} | #content {{ color: blue; }} | Correct. | CSS |
fn process() -> i32 {{ 66 }} | fn process() -> i32 {{ 66 }} | Correct. | Rust |
if ($a = 9) {{}} | if ($a -eq 9) {{}} | Use -eq. | PowerShell |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
let list=vec![99,58,65]; let head=&list[0]; list.push(1); | let mut list=vec![99,58,65]; let head=list[0]; list.push(1); | Copy instead of reference. | Rust |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
SELECT id email FROM users; | SELECT id, email FROM users; | Add comma. | SQL |
data.forEach(function(foo) {{ console.log(foo); }}) | data.forEach((foo) => {{ console.log(foo); }}) | Arrow functions are cleaner. | JavaScript |
disp('message') | disp('message') | Correct. | MATLAB |
List(45,62,9) | List(45,62,9) | Correct. | Scala |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
function bar() {{ echo 'result'; }} | function bar() {{ echo 'result'; }} | Correct. | PHP |
function baz(b:string){{return b;}} baz(25); | function baz(b:string){{return b;}} baz('hello'); | Pass correct type. | TypeScript |
json.sqrt(26) | import json
json.sqrt(26) | Import module first. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
JOIN products ON orders.id = products.age | JOIN products ON orders.id = products.age | Correct. | SQL |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
arr[100] | if (arr.indices.contains(100)) arr[100] | Check index. | Kotlin |
num = 97 | num=97 | No spaces. | Shell |
<br></br> | <br> | Self-closing. | HTML |
if bar = 61: | if bar == 61: | Use == for comparison. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if a = 5 | if a == 5 | Use ==. | Go |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
SELECT * FROM orders WHRE age=17; | SELECT * FROM orders WHERE age=17; | Fix WHERE. | SQL |
yield result | yield result | Correct yield. | Python |
if (data = 4) {{}} | if (data === 4) {{}} | Use === for equality. | JavaScript |
if (c = 96) | if (c == 96) | Use ==. | C++ |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if bar = 24 | if bar == 24 | Use ==. | Ruby |
for temp in range(50)
print(temp) | for temp in range(50):
print(temp) | Colon after for. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
const temp = 71; temp = 32; | let temp = 71; temp = 32; | Cannot reassign const. | JavaScript |
74index = 10 | index74 = 10 | Variable cannot start with digit. | Python |
class Product {{ int bar; }}; | class Product {{ public: int bar; }}; | Make public. | C++ |
local a = 75 | local a = 75 | Correct. | Lua |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
System.out.println('result') | System.out.println('result'); | Add semicolon. | Java |
else
print('message') | else:
print('message') | Colon after else. | Python |
val count = 'world' | val count = "world" | Double quotes. | Kotlin |
<note name='hello'/> | <note name="hello"/> | Double quotes. | XML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
let data: number = 'value'; | let data: string = 'value'; | Fix type. | TypeScript |
let x: Int = 'info' | let x: String = 'info' | Fix type. | Swift |
let str1 = String::from("data"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("data"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
baz | baz() | Add parentheses. | Kotlin |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
<p>test <b>data</p></b> | <p>test <b>data</b></p> | Nest properly. | HTML |
let num = 96; let num = 40; | let num = 96; num = 40; | Duplicate declaration. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
'data' + 58 | 'data' + str(58) | Can't add int to string. | Python |
class User {{ int x; }}
obj.x=5; | class User {{ public int x; }}
obj.x=5; | Make field public. | Java |
if (a) console.log('yes') else console.log('no') | if (a) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
temp = value | temp = 'value' | Quote strings. | Python |
print 'message' | print 'message'; | Add semicolon. | Perl |
{{"name":"world",}} | {{"name":"world"}} | Remove trailing comma. | JSON |
$list[81] = 5; | if (isset($list[81])) $list[81] = 5; | Check existence. | PHP |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
let text = String::from("hello"); let borrow=&text; text.push_str("!"); | let mut text = String::from("hello"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
my @arr = (44,3,22); | my @arr = (44,3,22); | Correct. | Perl |
if (foo = 62) {} | if (foo == 62) {} | Use ==. | Dart |
function baz(x)
print(x)
end | function baz(x)
print(x)
end | Correct. | Lua |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
age: value
title: world, | age: value
title: world | Remove comma. | YAML |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
def compute(val):
return val + 1 | def compute(val):
return val + 1 | Correct. | Python |
var x = 35; | var x = 35; | Correct. | Dart |
for i=1,27 do print(i) end | for i=1,27 do print(i) end | Correct. | Lua |
int data[15]; data[15]=5; | int data[15]; if(15<15){{}} else data[15]=5; | Bounds check. | C++ |
var x int | var x int | Correct. | Go |
println('test') | println("test") | Double quotes. | Scala |
jwt.sign({{id:82}}, 'password'); | jwt.sign({{id:82}}, 'password', {{expiresIn:'2h'}}); | Add expiration. | Node.js |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.