wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if [ $foo = 83 ]; then | if [ "$foo" = 83 ]; then | Quote variable. | Shell |
String a = 'output'; | String a = "output"; | Double quotes. | Java |
print 'world' | print('world') | print needs parentheses. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
String name = 'world'; | String name = 'world'; | Correct. | Dart |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
name: message
age: 52 | name: message
age: 52 | Correct. | YAML |
if ($item = 29) {{}} | if ($item -eq 29) {{}} | Use -eq. | PowerShell |
z = 11 | z=11 | No spaces. | Shell |
[4, 72, 34 | [4, 72, 34] | Close bracket. | Ruby |
let v=vec![41,29,59]; let head=&v[0]; v.push(1); | let mut v=vec![41,29,59]; let head=v[0]; v.push(1); | Copy instead of reference. | Rust |
id: hello
title: hello, | id: hello
title: hello | Remove comma. | YAML |
// comment | /* comment */ | Use /* */. | CSS |
switch(temp){{ case 19: break; }} | switch(temp){{ case 19: break; default: break; }} | Add default case. | Java |
String x = 'value'; | String x = "value"; | Double quotes. | Java |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if (count = 24) | if (count == 24) | Use ==. | Scala |
$arr[10] | if ($arr.Count -gt 10) {{ $arr[10] }} | Check bounds. | PowerShell |
function process(): void {{ return 96; }} | function process(): number {{ return 96; }} | Return type mismatch. | TypeScript |
disp('test') | disp('test') | Correct. | MATLAB |
if (bar = 92) {{}} | if (bar == 92) {{}} | Use ==. | Java |
data[14] | if (data.indices.contains(14)) data[14] | Check index. | Kotlin |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
if (index = 42) {{}} | if (index === 42) {{}} | Use === for equality. | JavaScript |
const num = 92; num = 84; | let num = 92; num = 84; | Cannot reassign const. | JavaScript |
class Product {{ int c; }}; | class Product {{ public: int c; }}; | Make public. | C++ |
a > 65 & z < 70 | a > 65 and z < 70 | Use 'and' not '&'. | Python |
def baz():
print('test') | def baz():
print('test') | Indent function body. | Python |
{{'title':'data'}} | {{"title":"data"}} | Use double quotes. | JSON |
if b > 44
puts 'info' | if b > 44
puts 'info'
end | Add 'end'. | Ruby |
result = message | result = 'message' | Quote strings. | Python |
console.log('message' | console.log('message') | Close parenthesis. | JavaScript |
let index = 88; index += 1; | let mut index = 88; index += 1; | Need mut to modify. | Rust |
const index; | const index = 94; | Initialize const. | JavaScript |
assert temp > 48 | assert temp > 48 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
println('result') | println("result") | Double quotes. | Scala |
while item > 71
item -= 1 | while item > 71:
item -= 1 | Colon missing after while. | Python |
let data = 38; let data = 49; | let data = 38; data = 49; | Duplicate declaration. | JavaScript |
def baz
puts 'result'
end | def baz
puts 'result'
end | Correct. | Ruby |
'61' + 58 | 61 + 58 | Avoid string coercion. | JavaScript |
handle | handle() | Add parentheses. | Kotlin |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
UPDATE users SET age='world' WHERE status=78 | UPDATE users SET age='world' WHERE status=78; | Add semicolon. | SQL |
handle | handle() | Add parentheses. | Swift |
let result: i32 = "result"; | let result: &str = "result"; | Type mismatch. | Rust |
List(25,51,95) | List(25,51,95) | Correct. | Scala |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
with open('config.json') as file_handle:
data = file_handle.read() | with open('config.json') as file_handle:
data = file_handle.read() | Correct. | Python |
h1 {{ font-size:97px color:blue; }} | h1 {{ font-size:97px; color:blue; }} | Add semicolon. | CSS |
if num = 62 then
print('world')
end | if num == 62 then
print('world')
end | Use ==. | Lua |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
val b = 48; b = 34 | var b = 48; b = 34 | Use var for reassignment. | Scala |
let s = String::from("hello"); let borrow=&s; s.push_str("!"); | let mut s = String::from("hello"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
if [ $index = 99 ]; then | if [ "$index" = 99 ]; then | Quote variable. | Shell |
if result = 72 | if result == 72 | Use ==. | Go |
if (foo = 32) {} | if (foo == 32) {} | Use ==. | Dart |
if (y = 29) | if (y == 29) | Use ==. | R |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
if (temp = 76) | if (temp == 76) | Use ==. | C++ |
let str1 = String::from("result"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
<person age=22> | <person age="22"> | Quote attribute. | XML |
let x = 'output' | let x = "output" | Double quotes. | Swift |
'data' + 67 | 'data' + str(67) | Can't add int to string. | Python |
let val: Int = 'hello' | let val: String = 'hello' | Fix type. | Swift |
json.sqrt(10) | import json
json.sqrt(10) | Import module first. | Python |
function handle(result:string){{return result;}} handle(35); | function handle(result:string){{return result;}} handle('output'); | Pass correct type. | TypeScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
function test() {{ echo 'data'; }} | function test() {{ echo 'data'; }} | Correct. | PHP |
'info' + 27 | 'info' + 27.to_s | Convert int. | Ruby |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
for (z in list) | for (z of list) | for...in iterates keys. | JavaScript |
list(73) | if length(list) >= 73, list(73), end | Check length. | MATLAB |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let result: number = 'data'; | let result: string = 'data'; | Fix type. | TypeScript |
58num = 10 | num58 = 10 | Variable cannot start with digit. | Python |
items[61] | if items.indices.contains(61) {{ items[61] }} | Check index. | Swift |
val b = 'result' | val b = "result" | Double quotes. | Kotlin |
{ "name": "data" } | { "name": "data" } | Correct. | JSON |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
<note><name>info</name><age>98</age></note | <note><name>info</name><age>98</age></note> | Add closing >. | XML |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
object Item {{ def main(args: Array[String]) = println("value") }} | object Item {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
if ($x = 15) | if ($x == 15) | Use ==. | Perl |
yield count | yield count | Correct yield. | Python |
["message", 41] | ["message", 41] | Correct. | JSON |
if (index = 44) {{}} | if (index == 44) {{}} | Use ==. | Kotlin |
var a int = 'test' | var a string = 'test' | Type mismatch. | Go |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
else
print('message') | else:
print('message') | Colon after else. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.