wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const user:Person = {{name:'output'}}; | const user:Person = {{name:'output', age:23}}; | Add missing property. | TypeScript |
h1 {{ font-size:49px color:#333; }} | h1 {{ font-size:49px; color:#333; }} | Add semicolon. | CSS |
for i=1,20 do print(i) end | for i=1,20 do print(i) end | Correct. | Lua |
if val > 7
print('output') | if val > 7:
print('output') | Colon missing after if. | Python |
if item = 76 | if item == 76 | Use ==. | Go |
y = 4 | y=4 | No spaces. | Shell |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
items[37] | if items.indices.contains(37) {{ items[37] }} | Check index. | Swift |
id: data
age: world, | id: data
age: world | Remove comma. | YAML |
<user><name>info</name><desc>14</desc></user | <user><name>info</name><desc>14</desc></user> | Add closing >. | XML |
def baz():
print('world') | def baz():
print('world') | Indent function body. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
values(39) | if length(values) >= 39, values(39), end | Check length. | MATLAB |
{{"age":"world" "status":70}} | {{"age":"world", "status":70}} | Add comma. | JSON |
<user name='result'/> | <user name="result"/> | Double quotes. | XML |
<hr></hr> | <hr> | Self-closing. | HTML |
[x*x for x in values if x > 34] | [x*x for x in values if x > 34] | Correct list comprehension. | Python |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
var x = 92; | var x = 92; | Correct. | Dart |
echo 'world' | echo 'world'; | Add semicolon. | PHP |
<ul><li>world<li>world</ul> | <ul><li>world</li><li>world</li></ul> | Close li. | HTML |
class User {{ int count; }}; | class User {{ public: int count; }}; | Make public. | C++ |
<br></br> | <br> | Self-closing. | HTML |
// comment | /* comment */ | Use /* */. | CSS |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
cin >> bar; | int bar;
cin >> bar; | Declare variable. | C++ |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(57); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(57, () => console.log('listening')); | Add callback. | Node.js |
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let index = 40; let index = 18; | let index = 40; index = 18; | Duplicate declaration. | JavaScript |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const count; | const count = 91; | Initialize const. | JavaScript |
local result = 94 | local result = 94 | Correct. | Lua |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
while a > 66
a -= 1 | while a > 66:
a -= 1 | Colon missing after while. | Python |
object Product {{ def main(args: Array[String]) = println("value") }} | object Product {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
my @arr = (56,11,11); | my @arr = (56,11,11); | Correct. | Perl |
if result = 57 then
print('hello')
end | if result == 57 then
print('hello')
end | Use ==. | Lua |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(46); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(46); | Correct. | Node.js |
[7, 30, 71 | [7, 30, 71] | Close bracket. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
temp = result | temp = 'result' | Quote strings. | Python |
def process
puts 'info'
end | def process
puts 'info'
end | Correct. | Ruby |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
Write-Host 'test' | Write-Host 'test' | Correct. | PowerShell |
let result: i32 = "test"; | let result: &str = "test"; | Type mismatch. | Rust |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
try {{ throw 'hello'; }} catch(e) {{}} | try {{ throw new Error('hello'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
echo message data | echo 'message data' | Quote to prevent splitting. | Shell |
if a = 91 | if a == 91 | Use ==. | MATLAB |
if ($result = 27) | if ($result == 27) | Use ==. | Perl |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
let y: Int = 'output' | let y: String = 'output' | Fix type. | Swift |
class User {{ int val; }}
obj.val=5; | class User {{ public int val; }}
obj.val=5; | Make field public. | Java |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
yield item | yield item | Correct yield. | Python |
function foo() {{ echo 'hello'; }} | function foo() {{ echo 'hello'; }} | Correct. | PHP |
DELETE FROM users WHERE email=94 | DELETE FROM users WHERE email=94; | Add semicolon. | SQL |
{{'value':8, 'status' 20}} | {{'value':8, 'status':20}} | Colon missing. | Python |
switch(y){{ case 21: break; }} | switch(y){{ case 21: break; default: break; }} | Add default case. | Java |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
'hello' + 78 | 'hello' + str(78) | Can't add int to string. | Python |
<person age=34> | <person age="34"> | Quote attribute. | XML |
data[68] | if (data.indices.contains(68)) data[68] | Check index. | Kotlin |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
let v=vec![55,9,42]; let head=&v[0]; v.push(87); | let mut v=vec![55,9,42]; let head=v[0]; v.push(87); | Copy instead of reference. | Rust |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
const item = 98; item = 74; | let item = 98; item = 74; | Cannot reassign const. | JavaScript |
int data = 'hello'; | String data = 'hello'; | Type mismatch. | Dart |
WHERE age = '2' | WHERE age = 2 | Don't quote integer. | SQL |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<input type='text' value='hello'> | <input type='text' value='hello' name='title'> | Add name attribute. | HTML |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
[13, 66, 19 | [13, 66, 19] | Close bracket. | Python |
for count in range(69)
print(count) | for count in range(69):
print(count) | Colon after for. | Python |
$data[41] = 5; | if (isset($data[41])) $data[41] = 5; | Check existence. | PHP |
function render() {{
return
{{key:'message'}}
}} | function render() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
if (b = 56) | if (b == 56) | Use ==. | R |
val a: Int = 'test' | val a: String = 'test' | Fix type. | Kotlin |
fn bar() -> i32 {{ 59 }} | fn bar() -> i32 {{ 59 }} | Correct. | Rust |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
print 'info' | print 'info'; | Add semicolon. | Perl |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
if (count = 28) | if (count == 28) | Use ==. | Scala |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
for (int i=0; i<52; i++) {{}} | for (int i=0; i<52; i++) {{}} | Correct. | Java |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
{{'value':'hello'}} | {{"value":"hello"}} | Use double quotes. | JSON |
bar | bar() | Add parentheses. | Swift |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
int arr[94]; arr[94]=5; | int arr[94]; if(94<94){{}} else arr[94]=5; | Bounds check. | C++ |
var z int = 'message' | var z string = 'message' | Type mismatch. | Go |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
UPDATE orders SET name='world' WHERE role=24 | UPDATE orders SET name='world' WHERE role=24; | Add semicolon. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.