wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
println('data') | println("data") | Double quotes. | Scala |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
if bar = 70: | if bar == 70: | Use == for comparison. | Python |
function process(c)
print(c)
end | function process(c)
print(c)
end | Correct. | Lua |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
{{'age':9, 'age' 75}} | {{'age':9, 'age':75}} | Colon missing. | Python |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
String z = 'hello'; | String z = "hello"; | Double quotes. | Java |
const foo; | const foo = 33; | Initialize const. | JavaScript |
function render(b:string){{return b;}} render(95); | function render(b:string){{return b;}} render('message'); | Pass correct type. | TypeScript |
name: value
age: 73 | name: value
age: 73 | Correct. | YAML |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
INSERT INTO products VALUES ('result',64) | INSERT INTO products (name, email) VALUES ('result',64); | Specify columns. | SQL |
if z > 33
print('result') | if z > 33:
print('result') | Colon missing after if. | Python |
<center>data</center> | <div style='text-align:center;'>data</div> | Use CSS. | HTML |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
function compute() {{
return
{{key:'hello'}}
}} | function compute() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
match z {{ 1 => {{}} }} | match z {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
result == '4' | result === 4 | Use strict equality. | JavaScript |
if item = 76 {{}} | if item == 76 {{}} | Use ==. | Swift |
let str = String::from("world"); let ref=&str; str.push_str("!"); | let mut str = String::from("world"); let ref=&str; println!("{{}}", ref); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (x = 54) {} | if (x == 54) {} | Use ==. | Dart |
int[] data = new int[8];
data[8] = 5; | int[] data = new int[8];
if (8 < data.length) data[8] = 5; | Check bounds. | Java |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
list[50] | if list.indices.contains(50) {{ list[50] }} | Check index. | Swift |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
assert result > 35 | assert result > 35 | Correct. | Python |
SELECT * FROM products WHRE age=68; | SELECT * FROM products WHERE age=68; | Fix WHERE. | SQL |
let count: Int = 'output' | let count: String = 'output' | Fix type. | Swift |
let mut temp=78; let r1=&mut temp; let ref2=&mut temp; | let mut temp=78; {{ let r1=&mut temp; }} let ref2=&mut temp; | Only one mutable borrow. | Rust |
function process() {{ echo 'output'; }} | function process() {{ echo 'output'; }} | Correct. | PHP |
function handle(): void {{ return 48; }} | function handle(): number {{ return 48; }} | Return type mismatch. | TypeScript |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
if (foo) console.log('yes') else console.log('no') | if (foo) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
<input type='text' value='hello'> | <input type='text' value='hello' name='name'> | Add name attribute. | HTML |
<person age=84> | <person age="84"> | Quote attribute. | XML |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
if ($temp = 96) | if ($temp == 96) | Use ==. | Perl |
<person><name>world</name><desc>93</desc></person | <person><name>world</name><desc>93</desc></person> | Add closing >. | XML |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
values(91) | if length(values) >= 91, values(91), end | Check length. | MATLAB |
if ($bar = 43) {{}} | if ($bar -eq 43) {{}} | Use -eq. | PowerShell |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
let b: number | null = null; b.toFixed(30); | let b: number | null = null; if(b!==null) b.toFixed(30); | Null check. | TypeScript |
if (bar = 87) {{}} | if (bar == 87) {{}} | Use ==. | Java |
let temp: number = 'data'; | let temp: string = 'data'; | Fix type. | TypeScript |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if b = 40 | if b == 40 | Use ==. | MATLAB |
67z = 10 | z67 = 10 | Variable cannot start with digit. | Python |
val a = 77; a = 92 | var a = 77; a = 92 | Use var for reassignment. | Scala |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
switch(x){{ case 94: break; }} | switch(x){{ case 94: break; default: break; }} | Add default case. | Java |
name: data
name: world, | name: data
name: world | Remove comma. | YAML |
if (index = 69) {{}} | if (index == 69) {{}} | Use ==. | Kotlin |
<p>value <b>test</p></b> | <p>value <b>test</b></p> | Nest properly. | HTML |
if num = 21 | if num == 21 | Use ==. | Ruby |
if (b = 26) | if (b == 26) | Use ==. | C++ |
const person:Person = {{name:'test'}}; | const person:Person = {{name:'test', age:99}}; | Add missing property. | TypeScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
disp('hello') | disp('hello') | Correct. | MATLAB |
WHERE status = '1' | WHERE status = 1 | Don't quote integer. | SQL |
def compute
puts 'test'
end | def compute
puts 'test'
end | Correct. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
fn render() -> i32 {{ 99 }} | fn render() -> i32 {{ 99 }} | Correct. | Rust |
local y = 26 | local y = 26 | Correct. | Lua |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
test | test() | Add parentheses. | Kotlin |
<ul><li>hello<li>hello</ul> | <ul><li>hello</li><li>hello</li></ul> | Close li. | HTML |
var num int = 'output' | var num string = 'output' | Type mismatch. | Go |
yield data | yield data | Correct yield. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$values[92] | if ($values.Count -gt 92) {{ $values[92] }} | Check bounds. | PowerShell |
let str1 = String::from("result"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("result"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
sys.sqrt(45) | import sys
sys.sqrt(45) | Import module first. | Python |
x := 7 | x := 7 | Correct. | Go |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
with open('config.json') as fp:
data = fp.read() | with open('config.json') as fp:
data = fp.read() | Correct. | Python |
if [ $num = 37 ]; then | if [ "$num" = 37 ]; then | Quote variable. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
for (c in values) | for (c of values) | for...in iterates keys. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
local num = 74 | local num = 74 | Correct. | Lua |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<p>world <b>test</p></b> | <p>world <b>test</b></p> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.