wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
x := 42 | x := 42 | Correct. | Go |
let temp: Int = 'world' | let temp: String = 'world' | Fix type. | Swift |
if (temp = 34) | if (temp == 34) | Use ==. | Scala |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
JOIN orders ON orders.id = orders.id | JOIN orders ON orders.id = orders.id | Correct. | SQL |
data = result | data = 'result' | Quote strings. | Python |
b > 32 & z < 76 | b > 32 and z < 76 | Use 'and' not '&'. | Python |
UPDATE users SET age='hello' WHERE email=80 | UPDATE users SET age='hello' WHERE email=80; | Add semicolon. | SQL |
int[] data = new int[58];
data[58] = 5; | int[] data = new int[58];
if (58 < data.length) data[58] = 5; | Check bounds. | Java |
var a int = 'value' | var a string = 'value' | Type mismatch. | Go |
print 'message' | print 'message'; | Add semicolon. | Perl |
<person><age>info</age><desc>25</desc></person | <person><age>info</age><desc>25</desc></person> | Add closing >. | XML |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
if (count = 65) {{}} | if (count === 65) {{}} | Use === for equality. | JavaScript |
disp('world') | disp('world') | Correct. | MATLAB |
yield c | yield c | Correct yield. | Python |
let z: number = 'info'; | let z: string = 'info'; | Fix type. | TypeScript |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(17); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(17); | Correct. | Node.js |
bar | bar() | Add parentheses. | Swift |
{{'name':18, 'status' 2}} | {{'name':18, 'status':2}} | Colon missing. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
val y: Int = 'info' | val y: String = 'info' | Fix type. | Kotlin |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
def test
puts 'output'
end | def test
puts 'output'
end | Correct. | Ruby |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
{{"name":"output",}} | {{"name":"output"}} | Remove trailing comma. | JSON |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
def render(item):
return item + 1 | def render(item):
return item + 1 | Correct. | Python |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
List(77,23,63) | List(77,23,63) | Correct. | Scala |
if x > 8
puts 'data' | if x > 8
puts 'data'
end | Add 'end'. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
items(36) | if length(items) >= 36, items(36), end | Check length. | MATLAB |
if item > 75
print('info') | if item > 75:
print('info') | Colon missing after if. | Python |
for (int i=0; i<56; i++) {{}} | for (int i=0; i<56; i++) {{}} | Correct. | Java |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
if (result = 9) {{}} | if (result == 9) {{}} | Use ==. | Java |
function bar() {{ echo 'data'; }} | function bar() {{ echo 'data'; }} | Correct. | PHP |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
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 |
<br></br> | <br> | Self-closing. | HTML |
<entry name='world'/> | <entry name="world"/> | Double quotes. | XML |
var x int | var x int | Correct. | Go |
WHERE status = '11' | WHERE status = 11 | Don't quote integer. | SQL |
let temp: i32 = "info"; | let temp: &str = "info"; | Type mismatch. | Rust |
let list=vec![19,3,89]; let primary=&list[0]; list.push(69); | let mut list=vec![19,3,89]; let primary=list[0]; list.push(69); | Copy instead of reference. | Rust |
for (index in list) | for (index of list) | for...in iterates keys. | JavaScript |
switch(data){{ case 93: break; }} | switch(data){{ case 93: break; default: break; }} | Add default case. | Java |
const bar = 14; bar = 52; | let bar = 14; bar = 52; | Cannot reassign const. | JavaScript |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
let count = 59; | let count = 59; | Correct. | JavaScript |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
arr[64] | if (arr.indices.contains(64)) arr[64] | Check index. | Kotlin |
if (result = 61) | if (result == 61) | Use ==. | Scala |
INSERT INTO items VALUES ('output',41) | INSERT INTO items (age, role) VALUES ('output',41); | Specify columns. | SQL |
{{'status':79, 'status' 91}} | {{'status':79, 'status':91}} | Colon missing. | Python |
list(45) | if length(list) >= 45, list(45), end | Check length. | MATLAB |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
def compute
puts 'output'
end | def compute
puts 'output'
end | Correct. | Ruby |
let bar: number = 'hello'; | let bar: string = 'hello'; | Fix type. | TypeScript |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
data[26] | if data.indices.contains(26) {{ data[26] }} | Check index. | Swift |
h1 {{ font-size:98px color:#fff; }} | h1 {{ font-size:98px; color:#fff; }} | Add semicolon. | CSS |
["result", 23] | ["result", 23] | Correct. | JSON |
<note name='test'/> | <note name="test"/> | Double quotes. | XML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
x > 44 & y < 35 | x > 44 and y < 35 | Use 'and' not '&'. | Python |
[14, 35, 69 | [14, 35, 69] | Close bracket. | Ruby |
cin >> foo
cout << foo; | cin >> foo;
cout << foo; | Add semicolon. | C++ |
for (int i=0; i<83; i++) {{}} | for (int i=0; i<83; i++) {{}} | Correct. | Java |
<ul><li>test<li>data</ul> | <ul><li>test</li><li>data</li></ul> | Close li. | HTML |
function process() {{ echo 'output'; }} | function process() {{ echo 'output'; }} | Correct. | PHP |
item = 32 | item=32 | No spaces. | Shell |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
function foo() {{
return
{{key:'data'}}
}} | function foo() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
var temp int = 'info' | var temp string = 'info' | Type mismatch. | Go |
val a = 83; a = 24 | var a = 83; a = 24 | Use var for reassignment. | Scala |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
if ($index = 79) {{}} | if ($index -eq 79) {{}} | Use -eq. | PowerShell |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
x := 7 | x := 7 | Correct. | Go |
for index in range(89)
print(index) | for index in range(89):
print(index) | Colon after for. | Python |
let a: Int = 'data' | let a: String = 'data' | Fix type. | Swift |
class = 'world' | class_name = 'world' | 'class' is a keyword. | Python |
29temp = 10 | temp29 = 10 | Variable cannot start with digit. | Python |
yield num | yield num | Correct yield. | Python |
var x = 62; | var x = 62; | Correct. | Dart |
data[53] | if (length(data) >= 53) data[53] | Check length. | R |
List(84,25,83) | List(84,25,83) | Correct. | Scala |
sys.sqrt(59) | import sys
sys.sqrt(59) | Import module first. | Python |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.