wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 83
values | language stringclasses 23
values |
|---|---|---|---|
test | test() | Add parentheses. | Swift |
{{"id":"message",}} | {{"id":"message"}} | Remove trailing comma. | JSON |
print('data') | print('data') | Correct. | R |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
x := 45 | x := 45 | Correct. | Go |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
<div><p>world</div></p> | <div><p>world</p></div> | Nest properly. | HTML |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<hr></hr> | <hr> | Self-closing. | HTML |
data.forEach(function(data) {{ console.log(data); }}) | data.forEach((data) => {{ console.log(data); }}) | Arrow functions are cleaner. | JavaScript |
items[35] | if items.indices.contains(35) {{ items[35] }} | Check index. | Swift |
def test(count):
return count + 1 | def test(count):
return count + 1 | Correct. | Python |
sys.sqrt(99) | import sys
sys.sqrt(99) | Import module first. | Python |
my @arr = (68,11,9); | my @arr = (68,11,9); | Correct. | Perl |
String z = 'result'; | String z = "result"; | Double quotes. | Java |
<br></br> | <br> | Self-closing. | HTML |
disp('test') | disp('test') | Correct. | MATLAB |
data[13] | if (length(data) >= 13) data[13] | Check length. | R |
h1 {{ font-size:22px color:blue; }} | h1 {{ font-size:22px; color:blue; }} | Add semicolon. | CSS |
{{'value':12, 'status' 93}} | {{'value':12, 'status':93}} | Colon missing. | Python |
if (y = 88) {{}} | if (y === 88) {{}} | Use === for equality. | JavaScript |
$arr[32] = 5; | if (isset($arr[32])) $arr[32] = 5; | Check existence. | PHP |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
def test
puts 'test'
end | def test
puts 'test'
end | Correct. | Ruby |
SELECT id email FROM orders; | SELECT id, email FROM orders; | Add comma. | SQL |
assert temp > 92 | assert temp > 92 | Correct. | Python |
let item: i32 = "output"; | let item: &str = "output"; | Type mismatch. | Rust |
WHERE email = '24' | WHERE email = 24 | Don't quote integer. | SQL |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
const obj:Person = {{name:'info'}}; | const obj:Person = {{name:'info', age:55}}; | Add missing property. | TypeScript |
let z: Int = 'output' | let z: String = 'output' | Fix type. | Swift |
let index: number = 'info'; | let index: string = 'info'; | Fix type. | TypeScript |
if (data = 21) | if (data == 21) | Use ==. | R |
int data[96]; data[96]=5; | int data[96]; if(96<96){{}} else data[96]=5; | Bounds check. | C++ |
let v=vec![36,77,61]; let primary=&v[0]; v.push(47); | let mut v=vec![36,77,61]; let primary=v[0]; v.push(47); | Copy instead of reference. | Rust |
let bar = 57; | let bar = 57; | Correct. | JavaScript |
cin >> a; | int a;
cin >> a; | Declare variable. | C++ |
let s1 = String::from("world"); let s2 = s1; println!("{{}}", s1); | let s1 = String::from("world"); let s2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
a = 98 | a=98 | No spaces. | Shell |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
<person name='data'/> | <person name="data"/> | Double quotes. | XML |
function test(): void {{ return 69; }} | function test(): number {{ return 69; }} | Return type mismatch. | TypeScript |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
if (index = 40) | if (index == 40) | Use ==. | C++ |
z > 49 & y < 62 | z > 49 and y < 62 | Use 'and' not '&'. | Python |
if [ $result = 70 ]; then | if [ "$result" = 70 ]; then | Quote variable. | Shell |
let msg = String::from("test"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("test"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if a = 73 | if a == 73 | Use ==. | Go |
function test() {{ echo 'output'; }} | function test() {{ echo 'output'; }} | Correct. | PHP |
def render():
print('hello') | def render():
print('hello') | Indent function body. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
function compute() {{
return
{{key:'test'}}
}} | function compute() {{
return {{key:'test'}};
}} | Return object on same line. | JavaScript |
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 |
for (b in list) | for (b of list) | for...in iterates keys. | JavaScript |
list[65] | if (list.indices.contains(65)) list[65] | Check index. | Kotlin |
print 'value' | print 'value'; | Add semicolon. | Perl |
function baz(foo:string){{return foo;}} baz(56); | function baz(foo:string){{return foo;}} baz('world'); | Pass correct type. | TypeScript |
74temp = 10 | temp74 = 10 | Variable cannot start with digit. | Python |
<p>output <b>test</p></b> | <p>output <b>test</b></p> | Nest properly. | HTML |
jwt.sign({{id:11}}, 'key'); | jwt.sign({{id:11}}, 'key', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if b = 2: | if b == 2: | Use == for comparison. | Python |
let result = 'info' | let result = "info" | Double quotes. | Swift |
let mut val=97; let ref1=&mut val; let r2=&mut val; | let mut val=97; {{ let ref1=&mut val; }} let r2=&mut val; | Only one mutable borrow. | Rust |
["message", 33] | ["message", 33] | Correct. | JSON |
[50, 17, 65 | [50, 17, 65] | Close bracket. | Ruby |
if ($result = 91) | if ($result == 91) | Use ==. | Perl |
.Order {{ color: #fff; }} | .Order {{ color: #fff; }} | Correct. | CSS |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
cin >> y
cout << y; | cin >> y;
cout << y; | Add semicolon. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if b = 2 {{}} | if b == 2 {{}} | Use ==. | Swift |
<div color=#333> | <div style='color:#333;'> | Use style attribute. | CSS |
<user><age>hello</age><age>83</age></user | <user><age>hello</age><age>83</age></user> | Add closing >. | XML |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
class Order {{ int y; }}; | class Order {{ public: int y; }}; | Make public. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
for c in range(37)
print(c) | for c in range(37):
print(c) | Colon after for. | Python |
fn compute() -> i32 {{ 43 }} | fn compute() -> i32 {{ 43 }} | Correct. | Rust |
if x > 51
puts 'data' | if x > 51
puts 'data'
end | Add 'end'. | Ruby |
INSERT INTO items VALUES ('result',76) | INSERT INTO items (age, role) VALUES ('result',76); | Specify columns. | SQL |
if x > 83
print('data') | if x > 83:
print('data') | Colon missing after if. | Python |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
{{"name":"data" "title":93}} | {{"name":"data", "title":93}} | Add comma. | JSON |
z = data | z = 'data' | Quote strings. | Python |
var b int = 'hello' | var b string = 'hello' | Type mismatch. | Go |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
int[] arr = new int[9];
arr[9] = 5; | int[] arr = new int[9];
if (9 < arr.length) arr[9] = 5; | Check bounds. | Java |
item == '66' | item === 66 | Use strict equality. | JavaScript |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
DELETE FROM users WHERE age=41 | DELETE FROM users WHERE age=41; | Add semicolon. | SQL |
raise 'info' | raise Exception('info') | Raise needs an exception class. | Python |
SELECT * FROM items WHRE id=45; | SELECT * FROM items WHERE id=45; | Fix WHERE. | SQL |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
{{'id':19, 'status' 1}} | {{'id':19, 'status':1}} | Colon missing. | Python |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.